Option Explicit
'References:
'Microsoft Shell Controls And Automation '(C:\Windows\System32\Shell32.dll)
Private Const ssfSYSTEM = 37 'System32 directory
Private Const ssfPROGRAMS = 2 'Program Files
Private Const ssfDESKTOP = 0
Private Const ssfDESKTOPDIRECTORY = 16 'Your profile desktop
Private Const ssfDRIVES = 17
Private Const ssfPERSONAL = 5 'My Documents folder
Private Const ssfCOMMONDESKTOPDIR = 25
Private Const ssfWINDOWS = 36 'Windows or Winnt directory
Private Sub Command1_Click()
Dim oShell As Shell32.Shell
Dim oFolder As Shell32.Folder
Set oShell = New Shell32.Shell
Set oFolder = oShell.NameSpace(ssfDESKTOPDIRECTORY)
If (Not oFolder Is Nothing) Then
Dim oFolderItem As Shell32.FolderItem
Dim i As Integer
Dim bFound As Boolean
For i = 1 To oFolder.Items.Count
Debug.Print oFolder.Items.Item(i)
If oFolder.Items.Item(i) = "Form1" Then
Set oFolderItem = oFolder.Items.Item(i)
bFound = True
Exit For
End If
Next
If bFound = False Then Exit Sub
If (Not oFolderItem Is Nothing) Then
Dim oShellLink As ShellLinkObject
Set oShellLink = oFolderItem.GetLink
If (Not oShellLink Is Nothing) Then
Debug.Print oShellLink.Path
Debug.Print oShellLink.Arguments
Debug.Print oShellLink.Description
Debug.Print oShellLink.ShowCommand
End If
Set oShellLink = Nothing
End If
Set oFolderItem = Nothing
End If
Set oFolder = Nothing
Set oShell = Nothing
End Sub