Attribute VB_Name = "modShortcuts" Option Explicit '============================================================================================================= ' ' modShortcuts Module ' ------------------- ' ' Created By : Kevin Wilson ' http://www.TheVBZone.com ( The VB Zone ) ' http://www.TheVBZone.net ( The VB Zone .NET ) ' ' Created On : October 03, 2004 ' Last Update : October 03, 2004 ' ' VB Versions : 5.0 / 6.0 ' ' Requires : STKIT432.DLL (Visual Basic 4.0 [32-bit] Setup Kit DLL) ' ' Description : This module makes it easy to create a shortcut anywhere on the hard drive that holds the ' START MENU/PROGRAMS folder. ' ' See Also : http://msdn.microsoft.com/library/en-us/dnaskdr/html/drgui10_2.asp (Ask Dr. GUI #57) ' http://support.microsoft.com/default.aspx?scid=kb;en-us;155303 (KB Article #155303) ' http://www.thevbzone.com/wwwboard/messages/1033.html ("The VB Zone" Sample Code) ' ' Example Use : ' ' '============================================================================================================= ' ' LEGAL: ' ' You are free to use this code as long as you keep the above heading information intact and unchanged. Credit ' given where credit is due. Also, it is not required, but it would be appreciated if you would mention ' somewhere in your compiled program that that your program makes use of code written and distributed by ' Kevin Wilson (www.TheVBZone.com). Feel free to link to this code via your web site or articles. ' ' You may NOT take this code and pass it off as your own. You may NOT distribute this code on your own server ' or web site. You may NOT take code created by Kevin Wilson (www.TheVBZone.com) and use it to create products, ' utilities, or applications that directly compete with products, utilities, and applications created by Kevin ' Wilson, TheVBZone.com, or Wilson Media. You may NOT take this code and sell it for profit without first ' obtaining the written consent of the author Kevin Wilson. ' ' These conditions are subject to change at the discretion of the owner Kevin Wilson at any time without ' warning or notice. Copyright© by Kevin Wilson. All rights reserved. ' '============================================================================================================= '------------------------------------------------------------------------------------------------------------- ' ' fCreateShellLink ' ' This API allows you to create a shortcut anywhere on the hard drive that holds the START MENU/PROGRAMS folder. ' ' Parameters: Use: ' ---------------------------------------------- ' lpstrFolderName Specifies the path of the shortcut relative to the START menu "Programs" folder ' (i.e. - "C:\Windows\Start Menu\Programs"). ' Passing "." will place the shortcut in the "Programs" folder. ' Passing "..\..\Desktop" will place the shortcut on the user's desktop. ' Passing "..\..\..\..\..\..\..\" will place the shortcut on the user's C:\ drive ' (or whichever drive root the START MENU/PROGRAMS is located on) ' ' lpstrLinkName Specifies the name of the shortcut to create (i.e. - "Microsoft Word") ' ' lpstrLinkPath Path to the file to create a shortcut for. Note that this can be the FULL path ' (i.e. - "C:\Program Files\MyProgram\MyProg.exe"), or just the name of the executable ' itself if it is located within the Windows search path (i.e. - "MyProg.exe") ' ' lpstrLinkArgs Specifies the command line parameters to pass to the program specified in the ' "lpstrLinkPath" parameter. This will normally be set to a BLANK or NULL string. ' ' Return: ' ------- ' Returns 1 if the function succeeds. Returns 0 if the function fails. ' '------------------------------------------------------------------------------------------------------------- Private Declare Function fCreateShellLink Lib "STKIT432.DLL" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long Public Function CreateShortcut(ByVal strFolder As String, ByVal strShortcutName As String, ByVal strShortcutTarget As String, ByVal strShortcutCommandLineParams As String) As Boolean ' If the shortcut name includes ".LNK", ".PIF", or ".URL"... remove that from the name Select Case UCase(Right(strShortcutName, 4)) Case ".LNK", ".PIF", ".URL" strShortcutName = Left(strShortcutName, Len(strShortcutName) - 4) End Select If fCreateShellLink(strFolder, strShortcutName, strShortcutTarget, strShortcutCommandLineParams) = 1 Then CreateShortcut = True Else CreateShortcut = False End If End Function