Create a shortcut

The following code provides an easy way to creating shortcuts (*.lnk files) using Visual Basic, by taking advantage of the STKIT432.DLL file. For code that does not require this file, click here.

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 to create the shortcut
'
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:\Winnt\system32\calc.exe", "")

You might also like...

Comments

Kym Manson Till the Roof comes off Till the Lights go out Till my Legs give out Can't shut my mouth I will not fall, my Wisdoms all.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Every language has an optimization operator. In C++ that operator is ‘//’”