Home » System & API » How to Add a shortcut in current users Desktop, Programs menu and Startup folder
How to Add a shortcut in current users Desktop, Programs menu and Startup folder
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 'System & API - How to Add a shortcut in current users Desktop, Programs menu and Startup folder Private Declare Function fCreateShellLink Lib "vb6stkit.dll" (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 Private Sub Form_Load() Dim strGroupName As String, strLinkName As String Dim strLinkPath As String, strLinkArguments As String, sParent As String Dim fPrivate As Boolean, fSuccess As Boolean strLinkName = "Shortcut to Calculator" strLinkPath = "c:\Windows\calc.exe" strLinkArguments = "" fPrivate = True 'Add shortcut to desktop. strGroupName = "..\..\Desktop" sParent = "$(Programs)" fSuccess = fCreateShellLink(strGroupName & vbNullChar, strLinkName, strLinkPath, strLinkArguments & _ vbNullChar, fPrivate, sParent) 'the path should never be enclosed in double quotes If fSuccess Then MsgBox "Created desktop shortcut" Else MsgBox "Unable to create desktop shortcut" End If 'Add shortcut to Programs menu. strGroupName = "$(Programs)" sParent = "$(Programs)" fSuccess = fCreateShellLink(strGroupName & vbNullChar, strLinkName, strLinkPath, strLinkArguments & _ vbNullChar, fPrivate, sParent) 'the path should never be enclosed in double quotes If fSuccess Then MsgBox "Created shortcut on Programs menu" Else MsgBox "Unable to create shortcut on Programs menu" End If ' Add shortcut to Startup folder of Programs menu. strGroupName = "Startup" sParent = "$(Programs)" fSuccess = fCreateShellLink(strGroupName & vbNullChar, strLinkName, strLinkPath, strLinkArguments & _ vbNullChar, fPrivate, sParent) 'the path should never be enclosed in double quotes If fSuccess Then MsgBox "Created shortcut in Startup folder" Else MsgBox "Unable to create shortcut in Startup folder" End If End Sub |
Related posts:
- How to Create Internet Shortcut on your Desktop
- How to Startup your application with Windows
- How to Get The Desktop Path
- How to Show/Hide all Desktop Icons
- How to get Network Information [current networks, domains, users, and user info] (for Windows NT/2000 only)
- How to Determine Windows Startup Mode
- How to get special folders
- How to set Desktop Wallpaper to None
- How to run your application at Windows Startup
- How to Get current user Name (in three ways)
Enjoy this article?
Filed under: System & API
Leave a comment
Sponsors
Link Back to us
Donations
If you are benefited from this site, please donate a small contribution to us. It will help to maintain this site better.