I must be doing something wrong. I only want to look at the ShortCut (ink) files, but this returns all files...If oFolder.Items.Item(i) = "Form1" Then
If in put in..Form1.ink", the loop passes it over.
I just want the ShortCut files...Thanks
VB Code:
  1. Option Explicit
  2. 'References:
  3. 'Microsoft Shell Controls And Automation '(C:\Windows\System32\Shell32.dll)
  4.  
  5. Private Const ssfSYSTEM = 37             'System32 directory
  6. Private Const ssfPROGRAMS = 2            'Program Files
  7. Private Const ssfDESKTOP = 0
  8. Private Const ssfDESKTOPDIRECTORY = 16   'Your profile desktop
  9. Private Const ssfDRIVES = 17
  10. Private Const ssfPERSONAL = 5            'My Documents folder
  11. Private Const ssfCOMMONDESKTOPDIR = 25
  12. Private Const ssfWINDOWS = 36            'Windows or Winnt directory
  13.  
  14. Private Sub Command1_Click()
  15.  
  16.     Dim oShell  As Shell32.Shell
  17.     Dim oFolder As Shell32.Folder
  18.    
  19.     Set oShell = New Shell32.Shell
  20.     Set oFolder = oShell.NameSpace(ssfDESKTOPDIRECTORY)
  21.         If (Not oFolder Is Nothing) Then
  22.             Dim oFolderItem As Shell32.FolderItem
  23.             Dim i As Integer
  24.             Dim bFound As Boolean
  25.             For i = 1 To oFolder.Items.Count
  26.                 Debug.Print oFolder.Items.Item(i)
  27.                 If oFolder.Items.Item(i) = "Form1" Then
  28.                
  29.                     Set oFolderItem = oFolder.Items.Item(i)
  30.                     bFound = True
  31.                     Exit For
  32.                 End If
  33.             Next
  34.             If bFound = False Then Exit Sub
  35.             If (Not oFolderItem Is Nothing) Then
  36.                 Dim oShellLink As ShellLinkObject
  37.                 Set oShellLink = oFolderItem.GetLink
  38.                 If (Not oShellLink Is Nothing) Then
  39.                     Debug.Print oShellLink.Path
  40.                     Debug.Print oShellLink.Arguments
  41.                     Debug.Print oShellLink.Description
  42.                     Debug.Print oShellLink.ShowCommand
  43.                    
  44.                 End If
  45.                 Set oShellLink = Nothing
  46.             End If
  47.             Set oFolderItem = Nothing
  48.         End If
  49.     Set oFolder = Nothing
  50.     Set oShell = Nothing
  51.    
  52. End Sub