5 replies
by sl-campbell
'Add this to the declarations section of the form or module,
'(In the same form or module where the below AddShortCutToDesktop sub is placed).
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
'Then, create this sub in the same form or module
Public Sub AddShortCutToDesktop(sLinkPathAndFile As String)
'sLinkPathAndFile is the file path and name: "C:\MYPATH\MYFILE"
Dim lReturn As Long
Dim sFolderName As String
Dim sLinkName As String
Dim sLinkArgs As String
On Error GoTo ErrHandler
'(Here you could also use an API call to get the Windows Desktop folder)
sDeskName = "..\..\Desktop"
sLinkDesc = "Shortcut to MYFILE"
sLinkArgs = vbNullString
lReturn = fCreateShellLink(sDeskName, sLinkDesc, sLinkPathAndFile, sLinkArgs)
If lReturn <> 1 Then GoTo ErrHandler
ExitProceedure:
Exit Sub
ErrHandler:
MsgBox "Error in Adding desktop short cut", vbOKCancel Or vbCritical, "Error in AddShortCutToDesktop"
On Error GoTo 0
End Sub
'Please note: This is only a "quick fix", and it would be better to ask Windows via an API call where theDesktop folder is. Also you may want to add some type of file checking to make sure you are passing a true path and file name to the sub.
by ckchong
by fenaikh
Hi
pls read this.
good luck
Mohamed
VB projects - Creating Desktop/Start menu shortcuts
by ckchong
by ckchong
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending