Results 1 to 5 of 5

Thread: Create Shortcuts - not resolved but answered, cheers

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Location
    Scotland
    Posts
    8

    Create Shortcuts - not resolved but answered, cheers

    Hi folks,

    Currently I am using the fCreateShellLink API call to create a number of shortcuts - however I am wondering if there are any other APIs which can be used to create shortcuts which are in the 'standard' libraries (e.g. Kernel32 etc).

    Does anyone know of any other APIs that can be used to create shortcuts??

    Ta in advance.
    Last edited by AidanG; Dec 11th, 2001 at 09:31 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    I believe that fCreateShellLink is the only API that is used for shortcuts. At least, this is the only API I've ever used, personally, and the only one I've ever seen in the numerous examples of creating shortcuts that are available on the various VB websites. Quite frankly, it would be nice if there were something that could be used out of a more standard library like, as you suggest, the Kernel.

  3. #3
    Lively Member
    Join Date
    Aug 2001
    Posts
    109
    id like to think there is ... because not everyone has that library.. yet they can still make shortcuts

  4. #4
    Hyperactive Member mvrp350's Avatar
    Join Date
    Feb 2001
    Location
    Best, the Netherlands
    Posts
    322
    I know it's not using API to the deepest extend but
    how about this one:

    VB Code:
    1. Private Sub CreateDesktopIcon()
    2.    
    3.     Dim objShortcut As Object
    4.     Dim objWshShell As IWshShell_Class
    5.    
    6.     Set objWshShell = New IWshShell_Class
    7.     Set objShortcut = objWshShell.CreateShortcut(GetDesktopFolderPath(Me.hWnd) & "\" & YourShortcut & ".lnk")
    8.    
    9.     objShortcut.TargetPath = YourPath
    10.     objShortcut.Arguments = "/" & YourArguments
    11.    
    12.            
    13.     objShortcut.WorkingDirectory = YourWDir
    14.     objShortcut.IconLocation = YourIconfile
    15.     objShortcut.Save
    16.    
    17.     DoEvents
    18.    
    19.     Set objWshShell = Nothing
    20.     Set objShortcut = Nothing
    21.    
    22. End Sub

    and to get the desktop:

    VB Code:
    1. Private Declare Function SHGetSpecialFolderLocation Lib "shell32" (ByVal hwndOwner As Long, ByVal nFolder As Integer, ppidl As Long) As Long
    2.  
    3. Private Declare Function SHGetPathFromIDList Lib "shell32" _
    4. Alias "SHGetPathFromIDListA" (ByVal pIdl As Long, ByVal szPath _
    5. As String) As Long
    6.  
    7. Private Const MAX_PATH = 260
    8.  
    9.  
    10. Private Function GetDesktopFolderPath(ByVal pHwnd As Long) As String
    11.  
    12.     Dim lReturn&
    13.     Dim lPidl&
    14.     Dim strPath$
    15.    
    16.     strPath$ = Space(MAX_PATH)
    17.     lReturn& = SHGetSpecialFolderLocation(pHwnd, 0, lPidl)
    18.  
    19.     ' Get lPidl& for this Id...
    20.     If lReturn = 0 Then
    21.        
    22.         lReturn = SHGetPathFromIDList(lPidl, strPath)
    23.        
    24.         ' Get Path from Item Id List
    25.             If lReturn = 1 Then 'If successeful
    26.            
    27.             GetDesktopFolderPath = Left(strPath$, _
    28.             InStr(strPath$, vbNullChar) - 1)
    29.  
    30.             End If
    31.     End If
    32.  
    33. End Function
    Last edited by mvrp350; Dec 12th, 2001 at 11:15 AM.

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    What is IWshShell_Class?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width