当前位置:编程学习 > VB >>

怎样用VB修改快捷方式的路径?

追问:需要声明API函数吗?
答案:
Private Sub Command1_Click()
Dim SourceLinkPath As String, targetPath As String, workPath As String
Dim shellObj, oShellLink

SourceLinkPath = "C:\1.lnk" ' 要修改的快捷方式
targetPath = "D:\" ' 把快捷方式的路径指向别处..

Set shellObj = CreateObject("WScript.shell")

Set oShellLink = shellObj.CreateShortcut(SourceLinkPath) ' CreateShortCut: 新建或者打开一个快捷方式
oShellLink.targetPath = targetPath
oShellLink.WindowStyle = 1 ' 窗口样式
oShellLink.Hotkey = "CTRL+SHIFT+F" ' 快捷键
oShellLink.IconLocation = "notepad.exe, 0" ' 图标
oShellLink.Description = "Shortcut Script" ' 注释
workPath = Mid(targetPath, 1, InStrRev(targetPath, "\"))
oShellLink.WorkingDirectory = workPath
oShellLink.Save ' 保存在SourceLinkPath

End Sub
凌云秀士

上一个:vb 代码 最好能对应翻译 谢谢
下一个:VB中有没有进制互转函数呢?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,