54SA.COM|专注于系统运维管理,为中国SA提供动力!
Getting online shouldn't be tough. $7.99 .COMs
系统管理员之家Banner
当前位置: 主页 > 编程开发 > VB开发 >

用VB无需DLL创建Windows快捷方式

时间:2011-12-15 16:48来源:未知 编辑:admin

 用VB创建Windows开始菜单快捷方式

Option Explicit

Private Sub Command1_Click()

CreateProgManGroup Me, "测试", "test.grp"
CreateProgManItem Me, "d:\ghost.exe", "Ghost"
CreateProgManItem Me, "d:\setupQQ.exe", "QQ"

End Sub

Sub CreateProgManGroup(X As Form, GroupName$, GroupPath$)
Dim i As Integer
X.Label1.LinkTopic = "ProgMan|Progman"
X.Label1.LinkMode = 2
Rem 空循环使DDE有时间执行
For i = 1 To 10
DoEvents
Next
X.Label1.LinkTimeout = 100
Rem LinkExecute 是在DDE通道中传送这样的命令
'──建立一个名为GroupName $的程序组。
X.Label1.LinkExecute "[ CreateGroup (" + GroupName$ + Chr$(44) + GroupPath$ + ") ]"
X.Label1.LinkTimeout = 50 '恢复Label1 的属性值
X.Label1.LinkMode = 0
End Sub


Sub CreateProgManItem(X As Form, CmdLine$, IconTitle$)
Dim i As Integer
X.Label1.LinkTopic = "ProgMan|Progman"
X.Label1.LinkMode = 2
For i = 1 To 10
DoEvents
Next
X.Label1.LinkTimeout = 100
X.Label1.LinkExecute "[AddItem(" + CmdLine$ + Chr$(44) + IconTitle$ + Chr$(44) + ", ,) ]"
X.Label1.LinkTimeout = 50 '恢复Label1 的属性值
X.Label1.LinkMode = 0
Screen.MousePointer = 0
End Sub


  将程序建立成“启动”文件夹的捷径

Text1.LinkTopic = "Progman|Progman"
Text1.LinkMode = 2 '手动
Text1.LinkExecute "[ShowGroup(启动, 4)]"
Text1.LinkExecute "[AddItem(可执行文件完整路径, 捷径名称)]"


假设我们想把“c:\vb5db\myprog.exe”建立成“启动”资料夹名称为“我的程序”的捷径,则最后一行的 LinkExecute 应该如下:

Text1.LinkExecute "[AddItem(c:\vb5db\myprog.exe, 我的程序)]"


  在桌面上添加程序的快捷方式
  假如程序为C:\Program Files\MyProg\Prog.exe,需加参数/Para
  新键一个项目,添加命令按钮和标签各一个,把下面的代码加上去,一运行,你将如愿以偿! 

Option Explicit
Private Sub Command1_Click()
CreateGroup "MyProg", "", "", 2, True
CreateGroup "MyProg", "C:\ProgramFiles\MyProg\Prog.exe/Para", _
"Para", 3, True
End Sub
Sub CreateGroup(ByVal strGroup As String, ByVal strCmd As String, ByVal _
strTitle As String, ByVal intDDE As Integer, ByVal fLog As Boolean)
Const strCOMMA$ = ","
Const strRESTORE$ = ", 1)]"
Const strACTIVATE$ = ", 5)]"
Const strENDCMD$ = ")]"
Const strSHOWGRP$ = "[ShowGroup("
Const strADDGRP$ = "[CreateGroup("
Const strREPLITEM$ = "[ReplaceItem("

[责任编辑:admin]


------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
用户名:
最新评论 进入详细评论页>>