假如程序为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("
const stradditem$ = "[additem("
dim i as integer
dim sourcefile as string, destinationfile as string
form1.label1.linkmode = 0
for i% = 1 to 20
on error resume next
form1.label1.linktopic = "progman|progman" '设置发送端应用程序和主题
if err = 0 then exit for
doevents
next
form1.label1.linkmode = 2 '采用手动方式建立连接
for i% = 1 to 10
doevents
next
form1.label1.linktimeout = 100 '设置等待 dde 响应消息的时间。
if err = 0 then
select case intdde
case 1 '建立程序项
form1.label1.linkexecute straddgrp & strgroup & strendcmd
form1.label1.linkexecute stradditem & strcmd & strcomma & _
strtitle & string$(3, strcomma) & strendcmd
case 2 '建立程序组
form1.label1.linkexecute straddgrp & strgroup & strendcmd
form1.label1.linkexecute strshowgrp & strgroup & strrestore
case 3 '建立程序项,并复制一份添加到桌面
form1.label1.linkexecute straddgrp & strgroup & strendcmd
form1.label1.linkexecute stradditem & strcmd & strcomma & _
strtitle & string$(3, strcomma) & strendcmd
sourcefile = "c:\windows\start menu\programs\" & strgroup & _
"\" & strtitle & ".lnk" ' 指定源文件名。
destinationfile = "c:\windows\desktop\" & strtitle & ".lnk"
'指定目的文件名。
filecopy sourcefile, destinationfile
end select
end if
'断开dde联接
form1.label1.linkmode = 0
form1.label1.linktopic = ""
end sub
查看全部回复
我也来说两句
