发信人: cobe(cobe)
整理人: winsy(2003-03-05 16:27:58), 站内信件
|
以下转载于CSDN论坛
------------------------------------------------
主 题:关于"快捷方式"的几个问题 (引用 Windows Script Host Model) ....
作 者:playyuer
所属论坛:Visual Basic
问题点数:20
回复次数:1
发表时间:2001-7-29 16:44:53
关于"快捷方式"的几个问题 (引用 Windows Script Host Model):
1.如何获取某一已存在的快捷方式(*.lnk)的所有信息?
Dim x As New IWshRuntimeLibrary.IWshShell_Class
Dim y As IWshRuntimeLibrary.IWshShortcut_Class
Set y = x.CreateShortcut("..\..\XXX.lnk")
Dim s As String
s = "Arguments: " & y.Arguments & vbCrLf _
& "Description: " & y.Description & vbCrLf _
& "FullName: " & y.FullName & vbCrLf _
& "Hotkey: " & y.Hotkey & vbCrLf _
& "IconLocation: " & y.IconLocation & vbCrLf _
& "TargetPath: " & y.TargetPath & vbCrLf _
& "WindowStyle: " & y.WindowStyle & vbCrLf _
& "WorkingDirectory: " & y.WorkingDirectory
MsgBox s
2.如何在 Windows 任务栏中创建快捷方式?
Dim x As New IWshRuntimeLibrary.IWshShell_Class
Dim y As IWshRuntimeLibrary.IWshShortcut_Class
If VBA.Len(VBA.Trim(VBA.Dir(x.SpecialFolders.Item("AppData") & "\Microsoft\Internet Explorer\Quick Launch\"))) > 0 Then
Set y = x.CreateShortcut(x.SpecialFolders.Item("AppData") & "\Microsoft\Internet Explorer\Quick Launch\WinRAR.lnk")
y.TargetPath = "..\..\XXX.exe"
y.Save
End If
'下面是几种 Windows 特殊路径:
AllUsersDesktop
AllUsersStartMenu
AllUsersPrograms
AllUsersStartup
AppData
Desktop
Favorites
Fonts
MyDocuments
NetHood
PrintHood
Programs
Recent
SendTo
StartMenu
Startup
Templates
综上 CreateShortcut 是用来创建一个 WshShortcut 的对象, 只要不调用其 Save 方法,就不会真正改变快捷方式的属性。
-----------------------------------------------
转载结束
详细说明,可以参看MSDN,在里面可以找到CreateShortcut方法以及相关说明
---- ╭──────╮+-+-+-+-+-+-+-+-+-+-+-+
│ cobe │ VB小世界
│发贴子专用章│ 打印机监控程序
│ QQ号码 │
│250172│ 北京社区VB版
╰──────╯+-+-+-+-+-+-+-+-+-+-+-+ |
|