将应用程序快捷方式复制到启动文件夹 VB [英] copying app shortcut to startup folder VB
本文介绍了将应用程序快捷方式复制到启动文件夹 VB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将我的应用程序快捷方式复制到 Windows 启动文件夹的最简单/最好的方法是什么?
what is the easiest/best way to copy my app shortcut to windows startup folder ?
我想在notifyicon上下文菜单中添加一个复选框,当用户点击它时,我希望应用程序将快捷方式复制到启动文件夹,未选中时想删除它.
i want to put a check box to notifyicon context menu and when user click on it i want app to copy shortcut to startup folder and when unchecked wanna delete it.
谢谢
推荐答案
尝试这样的事情:
Option Explicit
Dim LinkPath As String
Private Sub Form_Load()
LinkPath = Environ("APPDATA") & _
"\Microsoft\Windows\Start Menu\Programs\Startup\" & _
App.exename & ".lnk"
Debug.Print LinkPath
End Sub
Private Sub CreateAppLinkInAutoStart()
'Windows Script Host Object Model
'IWshRuntimeLibrary
'on Windows 32 bit (x86):
'C:\Windows\System32\wshom.ocx
'on Windows 64 bit (x64):
'C:\Windows\SysWOW64\wshom.ocx
Dim shell As New WshShell
Dim link As WshShortcut
Set link = shell.CreateShortcut(LinkPath)
link.targetpath = App.Path & "\" & App.exename & ".exe"
link.WorkingDirectory = App.Path & "\"
Call link.Save
End Sub
Private Sub Check1_Click()
If Check1.Value = vbChecked Then
CreateAppLinkInAutoStart
Else
Kill LinkPath
End If
End Sub
这篇关于将应用程序快捷方式复制到启动文件夹 VB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文