How do you create shortcut for a application in VB6 code????? Thanks!
Printable View
How do you create shortcut for a application in VB6 code????? Thanks!
Here are codes to make a short cut in "C:" drive or you can change the destination to the Desktop. Also, it shows you how to make a shortcut to the internet.
Code:Option Explicit
'NOTE:
'In Visual Basic 5.0 & 6.0 = Vb5stkit.dll
'In Visual Basic 4.0 = Stkit432.dll
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 cmdRegular_Shortcut_Click()
'PURPOSE: Add to Startup Group
'Note that on Windows NT, the shortcut will not actually
'appear in the Startup group until your next reboot.
Call fCreateShellLink("\Startup", "Shortcut to Calculator", "c:\windows\calc.exe", "")
MsgBox "Shortcut of calculator has resided in \Startup"
'PURPOSE: Add to Desktop
'Call fCreateShellLink("..\..\Desktop", "Shortcut to Calculator", "c:\windows\calc.exe", "")
'PURPOSE: Add to Program Menu Group
'Call fCreateShellLink("", "Shortcut to Calculator", "c:\windows\calc.exe", "")
End Sub
Private Sub cmdInternet_Shortcut_Click()
Dim str_Shortcut_Name As String
Dim str_URL As String
str_Shortcut_Name = "C:\Shortcut Name.url"
str_URL = "URL= http://www.yahoo.com"
'PURPOSE: Write the Internet Shortcut file
Open str_Shortcut_Name For Output As #1
Print #1, "[InternetShortcut]"
Print #1, str_URL
Close #1
MsgBox "Internet shortcut has resided in C:\"
End Sub
From Developer Code Book
hthCode:'Declarations
'NOTE: In Visual Basic 5.0, change Stkit432.dll in the following
'statement to Vb5stkit.dll. Stkit432.dll is for Visual Basic 4.0
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
'Code:
Dim lReturn As Long
'Add to Desktop
lReturn = fCreateShellLink("..\..\Desktop", _
"Shortcut to Calculator", "c:\windows\calc.exe", "")
'Add to Program Menu Group
lReturn = fCreateShellLink("", "Shortcut to Calculator", _
"c:\windows\calc.exe", "")
'Add to Startup Group
'Note that on Windows NT, the shortcut will not actually appear
'in the Startup group until your next reboot.
lReturn = fCreateShellLink("\Startup", "Shortcut to Calculator", _
"c:\windows\calc.exe", "")
Thanks! But where can I get the STKIT432.DLL file? VB couldn't find the file.Quote:
Originally posted by QWERTY
From Developer Code Book
hthCode:'Declarations
'NOTE: In Visual Basic 5.0, change Stkit432.dll in the following
'statement to Vb5stkit.dll. Stkit432.dll is for Visual Basic 4.0
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
'Code:
Dim lReturn As Long
'Add to Desktop
lReturn = fCreateShellLink("..\..\Desktop", _
"Shortcut to Calculator", "c:\windows\calc.exe", "")
'Add to Program Menu Group
lReturn = fCreateShellLink("", "Shortcut to Calculator", _
"c:\windows\calc.exe", "")
'Add to Startup Group
'Note that on Windows NT, the shortcut will not actually appear
'in the Startup group until your next reboot.
lReturn = fCreateShellLink("\Startup", "Shortcut to Calculator", _
"c:\windows\calc.exe", "")