有时,我们想给自己的程序也加一个快捷方式,当然程序安装后,我们可以通过点击我们程序的可执行文件,右击选择添加桌面快捷方式来实现,但我们有时想通过编程自动实现,这怎么办呢?我们可以调用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
怎么样,很简单吧
新闻热点
疑难解答