#region 快捷方式
private static void CreateDesktopLnk()
{
string DesktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);
if (DesktopPath.ToLower().Equals(Application.StartupPath.ToLower()) == false)
CreateDesktopLnkEx(DesktopPath, ShortCutFileName);
//string StartupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
//CreateDesktopLnkEx(StartupPath, ShortCutFileName);
}
private static void CreateDesktopLnkEx(string LnkPath, string LnkFileName)
{
WshShell shell = new WshShell();
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(LnkPath + "\\" + LnkFileName);
shortcut.TargetPath = Application.ExecutablePath;
shortcut.Arguments = "";
shortcut.Description = AppName;
shortcut.WorkingDirectory = Application.StartupPath;
shortcut.IconLocation = Application.ExecutablePath + ",0";
shortcut.WindowStyle = 1;
shortcut.Save();
}
#endregion
之前想着如何让应用开机启动的时候,有想着去添加注册表之类的,非常的麻烦,WIN7以上的系统还涉及到管理员权限的问题。其实最方便的实现方法就是直接在系统的“启动”目录下建立一个快捷方式。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。