Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a Shortcut (.lnk) to a Specified Folder

Status
Not open for further replies.

StuH

Programmer
Mar 25, 2001
53
AU
Hi all,

Wondering if anyone has any clue about this. I know how to create a shortcut on the desktop to a file (with an association) or an exe, but how do you create an lnk file on the desktop that is a shortcut to a folder using VB6?

Manually in Windows, this is done by right-click-dragging the folder you want in My Computer or Explorer to the desktop and choosing Create Shortcut Here. Opening the shortcut displays the folder contents in My Computer.

How do you create the same thing for a specified folder path?

Any help appreciated.

Stu.
 
I don't usually answer my own questions, but I have found the perfect solution (although I don't think it meant to do what I wanted it to do).

The solution uses the Windows API, in particular, the Windows Script Host Object Model. Go here:


There is a sample app with code not only for creating program/folder shortcuts, but for .URL shortcuts as well. And it's as easy as. My app is done, I'm a happy man!

Stu.
 
StuH, if you had been using [tt]fCreateShellLink[/tt] you might have noticed that the didn't care whether it was creating a link to a folder or an executable.

If you hadn't tried this, see thread711-157797.

Try...
[tt]
LinkName$ = "My Desktop Link"
AppLoc$ = "C:\"
[/tt]
...run the project, click Command1 and double-click on the new desktop link. It will open an Explorer window to the C:\ folder.
VCA.gif
 
Thanks Alt255.

I tested this solution and yes, it does work - except you have to ship the VB5STKIT.DLL (or vb6stkit.dll) with your app. The solution I found is standalone.

But I did note your solution allows you to change the default icon for the shortcut - that maybe handy one day!

Thanks,
Stu.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top