VB projects - Creating Desktop/Start menu shortcuts
Description: Writing the program that creates shortcut to specified application in selected Windows special folder. Select ...\Desktop to create shortcut on Desktop, select ...\Start Menu to create shortcut in Start Menu, etc.
Minimum requirements: vb5, Windows Scripting Host Object
Download: source code
Screenshot:

Project: Standard EXE
Controls: txtPath (textbox), txtName (textbox), cmdBrowse (button), cmdCreate (button), lst (listbox), dlg (common dialog control)
Additional project references: Windows Scripting Host Object
Code:
Dim wShell As IWshShell_Class
Private Sub cmdBrowse_Click()
dlg.FileName = "*.exe"
dlg.ShowOpen
txtPath = dlg.FileName
End Sub
Private Sub cmdCreate_Click()
Dim wShortcut As IWshShortcut_Class
If Dir(txtPath) = "" Or Trim(txtName) = "" Or
lst.ListIndex = -1 Then
MsgBox "Error"
Else
Set wShortcut =
wShell.CreateShortcut(lst.List(lst.ListIndex) & "\" & txtName &
".lnk")
wShortcut.TargetPath = txtPath
wShortcut.Save
End If
End Sub
Private Sub Form_Load()
Dim temp
Set wShell = New IWshShell_Class
For Each temp In wShell.SpecialFolders
lst.AddItem temp
Next
End Sub
|