1. Start a New Standard.Exe Project.
2. Add a ListBox (List1) to Form1.
3. Copy/Paste the following into the Form1 code window.
4. CHANGE the i_strShortcut variable to a valid Shortcut.
5. Press F5 to run. Click on VB Menu -> View -> Immediate Window and you will see all pertinent Shortcut information for the Link specified.
<----- Code begin ----->
Option Explicit
Private Sub Form_Load()
Dim strLinkSource As String
strLinkSource = "c:\win95b\desktop\windows explorer.lnk" ' <-- CHANGE
Dim strLinkTarget As String
strLinkTarget = "c:\win95b\desktop\TEST.lnk" ' <-- CHANGE
Call x_Link_Read(strLinkSource)
Call x_Link_Copy(strLinkSource, strLinkTarget)
End Sub
Private Sub x_Link_Copy(ByVal i_strSource As String, ByVal i_strTarget As String)
If Dir(i_strSource) = "" Then
MsgBox i_strSource & " NOT FOUND", vbCritical
Exit Sub
End If
If Dir(i_strTarget) <> "" Then
MsgBox i_strTarget & " ALREADY EXISTS", vbCritical
Exit Sub
End If
Dim wshShell As Object
Set wshShell = CreateObject("WScript.Shell"
Dim wshSource As Object
Set wshSource = wshShell.CreateShortcut(i_strSource)
With wshSource
Call x_Link_Write _
(i_strTarget, _
.Arguments, _
.Description, _
.Hotkey, _
.IconLocation, _
.TargetPath, _
.WindowStyle, _
.WorkingDirectory)
End With
Set wshShell = Nothing
End Sub
Private Sub x_Link_Read(ByVal i_strShortcut As String)
If Dir(i_strShortcut) = "" Then
MsgBox i_strShortcut & " NOT FOUND", vbCritical
Exit Sub
End If
Dim wshShell As Object
Set wshShell = CreateObject("WScript.Shell"
Dim wshLink As Object
Set wshLink = wshShell.CreateShortcut(i_strShortcut)
List1.Clear
List1.AddItem UCase(i_strShortcut)
With wshLink
List1.AddItem "Arguments: " & .Arguments
List1.AddItem "Description: " & .Description
List1.AddItem "FullName: " & .FullName
List1.AddItem "HotKey: " & .Hotkey
List1.AddItem "IconLocation: " & .IconLocation
List1.AddItem "TargetPath: " & .TargetPath
List1.AddItem "WindowStyle: " & .WindowStyle
List1.AddItem "WorkingDirectory: " & .WorkingDirectory
End With
Set wshShell = Nothing
End Sub
Private Sub x_Link_Write _
(ByVal i_strShortcut As String, _
ByVal i_strArguments As String, _
ByVal i_strDescription As String, _
ByVal i_strHotkey As String, _
ByVal i_strIconLocation As String, _
ByVal i_strTargetPath As String, _
ByVal i_strWindowStyle As String, _
ByVal i_strWorkingDirectory As String)
Dim wshShell As Object
Set wshShell = CreateObject("WScript.Shell"
Dim wshLink As Object
Set wshLink = wshShell.CreateShortcut(i_strShortcut)
With wshLink
.Arguments = i_strArguments
.Description = i_strDescription
.Hotkey = i_strHotkey
.IconLocation = i_strIconLocation
.TargetPath = i_strTargetPath
.WindowStyle = i_strWindowStyle
.WorkingDirectory = i_strWorkingDirectory
End With
wshLink.Save
Set wshShell = Nothing
End Sub
<----- Code End ----->