有時,我們想為自己的程式也加一個快捷方式,當然程式安裝後,我們可以透過點擊我們程式的可執行文件,右鍵選擇新增桌面捷徑來實現,但我們有時想透過程式設計自動實現,這怎麼辦呢?我們可以呼叫API函數來實現,下面給出了原始碼:
Private Declare Function fCreateShellLink Lib vb5stkit.DLL (ByVal _
lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal _
lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long
Private Sub MakeShortCuts()
Dim lReturn As Long
Dim MyPath As String
Dim MyName As String
MyPath = App.Path
MyName = App.EXEName
'增加到桌面
lReturn = fCreateShellLink(../../Desktop, _
Shortcut to Net Timer, MyPath & / & MyName, )
'增加到啟動組
lReturn = fCreateShellLink(/啟動, Shortcut to Net Timer, _
MyPath & / & MyName, )
End Sub
怎麼樣,很簡單吧