〖请教〗关于快捷方式
vb吧
全部回复
仅看楼主
level 5
如何通过VB代码创建某程序的.lnk快捷方式?谢谢!
2009年10月04日 09点10分 1
level 7
16H
吧里才有过……
2009年10月04日 09点10分 2
level 5
呵呵,抱歉,我是手机党,不太清楚,怎么解决的?
2009年10月04日 09点10分 3
level 5
我找到了那帖,我主要是不清楚.lnk具体是如何用vb代码写出来的,还是有专门生成快捷方式的函数?请各位指点,谢谢!
2009年10月04日 09点10分 4
level 7
16H
'改了下 https://tieba.baidu.com/f?kz=648865960 里的
'即     https://tieba.baidu.com/f?kz=648865960
Function CreatLnk(FileName As String, LnkPath As String, Optional LnkIcon As String, Optional LnkHotKey As String) As Boolean
On Error GoTo Wr
    CreatLnk = True
    Dim oMyShortcut As Object
    Set oMyShortcut = CreateObject("Wscript.shell").CreateShortcut(LnkPath) '此处为快捷名称
    If Len(LnkIcon) Then oMyShortcut.IconLocation = LnkIcon                 '此处为快捷图标
    oMyShortcut.TargetPath = FileName                                       '此处为源文件
    If Len(LnkHotKey) Then oMyShortcut.Hotkey = LnkHotKey                   '此处为快捷热键
    oMyShortcut.Save
Exit Function
Wr: CreatLnk = False
End Function
'要用的时候,依次输入快捷方式的指向、自身路径、图标和热键即可,后两者可省略
Private Sub Command1_Click()
MsgBox IIf(CreatLnk(Text1.Text, Text2.Text), "创建快捷方式成功!", "抱歉,快捷方式创建失败!"), , "提示"
End Sub
2009年10月04日 11点10分 5
level 0
'改了下 https://tieba.baidu.com/f?kz=648865960 里的
'即     https://tieba.baidu.com/f?kz=648865960
Function CreatLnk(FileName As String, LnkPath As String, Optional LnkIcon As String, Optional LnkHotKey As String) As Boolean
On Error GoTo Wr
    CreatLnk = True
    Dim oMyShortcut As Object
    Set oMyShortcut = CreateObject("Wscript.shell").CreateShortcut(LnkPath) '此处为快捷名称
    If Len(LnkIcon) Then oMyShortcut.IconLocation = LnkIcon                 '此处为快捷图标
    oMyShortcut.TargetPath = FileName                                       '此处为源文件
    If Len(LnkHotKey) Then oMyShortcut.Hotkey = LnkHotKey                   '此处为快捷热键
    oMyShortcut.Save
Exit Function
Wr: CreatLnk = False
End Function
'要用的时候,依次输入快捷方式的指向、自身路径、图标和热键即可,后两者可省略
Private Sub Command1_Click()
MsgBox IIf(CreatLnk(Text1.Text, Text2.Text), "创建快捷方式成功!", "抱歉,快捷方式创建失败!"), , "提示"
End Sub
2009年10月04日 11点10分 6
level 0
谢谢5楼赐教,LAXFLKID
2009年10月05日 01点10分 7
1