-
January 30th, 2003, 04:13 AM
#1
Creating Shortcuts with VB
I currently have an app that runs under win9X, one of the features is to create shortcuts on the desktop, I know need the program on winXP but the API call I use no longer works!
Private Declare Function OSfCreateShellLink Lib "vb6stkit.dll" Alias "fCreateShellLink" _
(ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, _
ByVal lpstrLinkPath As String, ByVal lpstrLinkArguments As String, _
ByVal fPrivate As Long, ByVal sParent As String) As Long
Do you know why this is? is there a different line of code, the machine I am testing it on has all the right DLLs but it just wont work
Thanks for any help
-
January 30th, 2003, 05:08 AM
#2
-
January 30th, 2003, 06:20 AM
#3
Thanks for the site but that is the code i already have, it doesnt work on XP, i think it is to do with the first arguement, in all the info sources i have found it has had "..\..\desktop" but the desktop path in xp is different! any more help would be greatly appreciated!
Thanks
Si
-
January 30th, 2003, 10:06 AM
#4
There is another way to create a shortcut. To make the following code works, add a reference to Windows Script Host Model:
Code:
'code modified from
'http://www.vbforums.com/showthread.php?threadid=225479&highlight=shortcut+create
Dim WshShell As New WshShell
Dim oShellLink As WshShortcut
'Create and save the shortcut
'Here, it is important the the extension end by .lnk
Set oShellLink = WshShell.CreateShortcut( "C:\TestLink.lnk" )
With oShellLink
'Shortcut to which file (can be anything, .exe, .doc, ...)
.TargetPath = "C:\WINNT\SYSTEM32\calc.exe"
.WindowStyle = 1
.IconLocation = "C:\WINNT\SYSTEM32\calc.exe, 0"
.Arguments = ""
.Save
End With
Set WshShell = Nothing
Set oShellLink = Nothing
Note that you'll have to use GetSpecialFolders to know where is the ShortCut and change "C:\TestLink.lnk" by the desktop folder AND the name of the link
JeffB
-
January 31st, 2003, 06:20 AM
#5
That worked a treat thanx
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
|