主题:VB建立一个带参数的 的快捷方式怎么弄?
pyhone
[专家分:0] 发布于 2010-08-23 14:26:00
有没高手能给代码。。 最好不带DLL的··
回复列表 (共1个回复)
沙发
一江秋水 [专家分:9680] 发布于 2010-08-29 09:29:00
不知道你要带什么参数,所以下面我只提供建立快捷方式的一般方法
一、使用WSH
Dim fs, ws, fo, z As String
Set fs = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject("wscript.shell")
z = ws.SpecialFolders("Startup") & "\王牌桌面魔术师.lnk" '获取“启动”文件夹路径
Set fo = ws.CreateShortcut(z) '在“启动”中创建快捷方式
fo.TargetPath = App.Path & "\王牌桌面魔术师.exe" '设置快捷方式的目标程序
fo.WorkingDirectory = App.Path '设置工作目录
fo.IconLocation = App.Path & "\王牌桌面魔术师.exe, 0" '设置图标
fo.WindowStyle = 1 '设置风格为常规
'fo.Hotkey = "" '设置快捷键
fo.Description = "更换墙纸后自动退出" '添加注释
fo.Save
Set fo = Nothing
Set fs = Nothing
Set ws = Nothing
二、使用API函数
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
Sub Command1_Click()
Dim lReturn As Long
'添加到桌面
lReturn = fCreateShellLink("..\..\Desktop", "Shortcut to Calculator", "c:\windows\calc.exe", "")
'添加到程序组
lReturn = fCreateShellLink("", "Shortcut to Calculator", "c:\windows\calc.exe", "")
'添加到启动组
lReturn = fCreateShellLink("\Startup", "Shortcut to Calculator", "c:\windows\calc.exe", "")
End Sub
我来回复