|
-
Mar 5th, 2002, 09:48 PM
#1
Thread Starter
Addicted Member
DeskTop Shortcut
Hello,
In my VB application I added code in setup1 project to create desktop shortcut,
There is no problem with Win95/98/Me, but with Windows NT, If I am logging as administrator the shortcut is not created,
but if I log as any other user, the shortcut is created.
Here is the code:
-----------------
Private Sub CreateShortcut()
Dim lngReturn As Long
Dim intRes As Integer
Dim strDesktopDir As String
strDesktopDir = GetSpecialfolder(CSIDL_DESKTOP)
If Dir$(strDesktopDir, vbDirectory) <> "" Then
intRes = MsgBox("Would you like to create shortcut on Desktop?", vbYesNo, gstrTitle)
If intRes = vbYes Then
lngReturn = OSfCreateShellLink(strDesktopDir, conLinkName, gstrCdDir & conAppFileDir & conAppFileName, "", 0&, "")
End If
End If
End Sub
Public Function GetSpecialfolder(CSIDL As Long) As String
Dim r As Long
Dim IDL As ITEMIDLIST
Dim Path As String
'Get the special folder
r = SHGetSpecialFolderLocation(100, CSIDL, IDL)
If r = NOERROR Then
'Create a buffer
Path = Space$(512)
'Get the path from the IDList
r = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal Path)
'Remove the unnecessary chr$(0)'s
GetSpecialfolder = Left$(Path, InStr(Path, Chr$(0)) - 1)
Exit Function
End If
GetSpecialfolder = ""
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|