标题:
[转载]
调用VBS创建快捷方式
[打印本页]
作者:
chinanic
时间:
2007-4-14 20:41
标题:
调用VBS创建快捷方式
Function CreateShellLink(ByVal LinkFile As String, _
ByVal TargetPath As String, _
Optional ByVal WorkingDirectory As String, _
Optional ByVal Hotkey As String, _
Optional ByVal WindowStyle As Integer = 1, _
Optional ByVal IconLocation As String, _
Optional ByVal Description As String) As Long
On Error Resume Next
Re: With CreateObject("WScript.Shell").CreateShortcut(LinkFile)
If Err.Number = -2147352567 Then '后缀名错误
LinkFile = LinkFile & ".lnk"
Err.Clear
GoTo Re:
ElseIf Err.Number Then
CreateShellLink = Err
Exit Function
End If
.TargetPath = TargetPath
If LCase(Right(LinkFile, 3)) = "lnk" Then
.WindowStyle = WindowStyle
.WorkingDirectory = WorkingDirectory
If Len(Hotkey) Then .Hotkey = Hotkey
.Description = Description
If Len(IconLocation) Then .IconLocation = IconLocation
End If
.Save
End With
CreateShellLink = Err
End Function
复制代码
欢迎光临 黑色海岸线论坛 (http://bbs.thysea.com/)
Powered by Discuz! 7.2