'改了下
https://tieba.baidu.com/f?kz=648865960 里的
'即
https://tieba.baidu.com/f?kz=648865960Function 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