Results 1 to 5 of 5

Thread: Creating Shortcuts

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2002
    Location
    London
    Posts
    19

    Talking Creating Shortcuts

    I have been looking everywhere to find out howto create shortcuts, i know its possible by using the Win Api but just cant find the code, can you help me?

  2. #2
    DerFarm
    Guest
    Do you mean that you'd like to create HotKeys? I've been trying
    to do it for a few weeks now, and it's not that easy.

    The closest I've come yet is these guys:

    http://www.merrioncomputing.com/Download/index.htm

    They have a hotkey control that seems to work well. It takes
    some getting used to tho....

  3. #3
    Junior Member
    Join Date
    Jan 1999
    Location
    Pierre, SD USA
    Posts
    23
    Assuming you mean creating shell links (shortcuts on the desktop and in the start menu) you have a few different options.

    1. You can use fCreateShellLink from the VB Setup Kit (dll name depends on version of setup). The syntax is as such:

    fCreateShellLink(Target, Caption, Path, Command-line Arguments)

    Example:

    Private Declare Function fCreateShellLink Lib "VB5STKIT.DLL" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long

    Private Sub Form_Load()
    dim lngResult as Long

    lngResult = fCreateShellLink("c:\Windows\Desktop", "My Shortcut", "C:\myfile.exe", "")
    End Sub

    2. If you prefer to not use the Setup Kit's dll (which might be the case if you are putting your code into an Access App), you can trick Windows into creating one for you by placing a file in the "Recent Files" folder and then moving or copying the resulting shortcut to the desired location. The drawback with this is you have very little control over the shortcut...as in NONE! You can't change the path to the target, you can't add command-line parms, etc.

    Here are a couple of examples for this process:
    http://www.mvps.org/vbnet/index.html...rtcutcheat.htm
    http://www.vbcity.com/pubs/article.asp?alias=shortcut


    3. Finally, you can also use the Shell object of the Windows Scripting Host. This one doesn't require the use of API's; simply include the scripting host's ocx file in your project references. Drawback: more files to install, easy for VB but more difficult with Access, may not work if user has scripting turned off (I say "may" because I honestly don't know), and you apparently still cannot edit shortcuts...only create them.

    The Windows Scripting Host should already be on your machine if you have IE 6 (5 may have had it too, but I am unsure). If you don't, you can download it from here: http://www.microsoft.com/msdownload/.../scripting.asp

    For help using the scripting host you can go here: http://www.winguides.com/scripting/r...php?category=3


    That's the only ways I know. I did quite a bit of searching on my own, and if there is a dll that the API can use to create and manipulate shortcuts directly it isn't documented; at least not where I could ever find.

    For further help with the Windows API, I suggest http://www.allapi.net/

    Good Luck!
    Barrie A. Sargent
    Programmer/Analyst - VB/VBA

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Feb 2002
    Location
    London
    Posts
    19
    Thanx thats exactly what i was after!!!!!

  5. #5
    Junior Member
    Join Date
    Jan 1999
    Location
    Pierre, SD USA
    Posts
    23
    I found this helpful tool this morning and thought you might be interested in it:

    http://www.ssware.com/shelllnk/shelllnk.htm

    There are others like it, too. Simply go to your favorite search engine and type "shelllink"
    Barrie A. Sargent
    Programmer/Analyst - VB/VBA

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