怎样实现Vb创建桌面自定义图标的快捷方式呢

维诺之星小程序 2011-04-06 02:29:15
个位大侠,我学Vb不久,还是个菜鸟。谁能给我写段代码啊 怎样实现Vb创建桌面自定义图标的快捷方式呢
...全文
345 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
tiger413 2011-07-28
  • 打赏
  • 举报
回复
在VC下如何实现呢,各位大虾们,主要是这一句,
.IconLocation = WSH.ExpandEnvironmentStrings _
("%SystemRoot%\system32\SHELL32.dll,70") '图标,可以是自己的ico
比如我要把应用程序图标改成图片图标,.jpg快捷方式的样子。
在下面这里回贴给分。

http://topic.csdn.net/u/20110724/23/36dde568-2e94-4d26-8468-986bf051fbd0.html
苦苦的潜行者 2011-07-28
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 ptzxzc 的回复:]
引用 1 楼 dbcontrols 的回复:

先把三月份的帖子结了再说





VB code
Private Sub Command2_Click()
'引用windows scripting host object model

Dim WSH As WshShell
Dim Urllink……
[/Quote]


+++1
不错不结贴,csdn的人还是不欢迎的
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 dbcontrols 的回复:]
先把三月份的帖子结了再说
[/Quote]
呵呵,我喜欢的风格。
码之魂 2011-04-06
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 dbcontrols 的回复:]

先把三月份的帖子结了再说
[/Quote]



Private Sub Command2_Click()
'引用windows scripting host object model

Dim WSH As WshShell
Dim Urllink As WshShortcut
Dim DeskPath As String
Dim lnkName As String

Set WSH = New WshShell
DeskPath = WSH.SpecialFolders("Desktop") '获得桌面路径

'得到快捷方式
lnkName = Dir(DeskPath & "\*.lnk")
Debug.Print lnkName
While Len(lnkName)
Debug.Print lnkName
lnkName = Dir
Wend

'可以用wsh_shell.expandenvironmentstrings("%windir%")获得windows路径
Set Urllink = WSH.CreateShortcut(DeskPath & "\Test.lnk")
With Urllink
.TargetPath = "d:\test.txt" '目标
.IconLocation = WSH.ExpandEnvironmentStrings _
("%SystemRoot%\system32\SHELL32.dll,70") '图标,可以是自己的ico
.Hotkey = "ctrl+shift+F" '快捷键
.WorkingDirectory = "d:\" '起始位置
.WindowStyle = 1 '运行方式
.Description = "备注备注备注备注备注" '备注
.Arguments = StrArg '参数
End With
Urllink.Save '保存快捷方式

' '添加到桌面
'lReturn = fCreateShellLink("..\..\Desktop", "Shortcut to Calculator", "c:\windows\calc.exe", "")
''添加到程序组
'lReturn = fCreateShellLink("", "Shortcut to Calculator", "c:\windows\calc.exe", "")
''添加到启动组
'lReturn = fCreateShellLink("\Startup", "Shortcut to Calculator", "c:\windows\calc.exe", "")

End Sub
dbcontrols 2011-04-06
  • 打赏
  • 举报
回复
先把三月份的帖子结了再说

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧