用C#创建应用程序桌面快捷方式
2018-01-04 12:00
281 查看
private void CreateShortcutOnDesktop() { //添加引用 (com->Windows Script Host Object Model),using IWshRuntimeLibrary; String shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "快捷方式名称.lnk"); if (!System.IO.File.Exists(shortcutPath)) { // 获取当前应用程序目录地址 String exePath = Process.GetCurrentProcess().MainModule.FileName; IWshShell shell = new WshShell(); // 确定是否已经创建的快捷键被改名了 foreach (var item in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "*.lnk")) { WshShortcut tempShortcut = (WshShortcut)shell.CreateShortcut(item); if (tempShortcut.TargetPath == exePath) { return; } } WshShortcut shortcut = (WshShortcut)shell.CreateShortcut(shortcutPath); shortcut.TargetPath = exePath; shortcut.Arguments = "";// 参数 shortcut.Description = "应用程序说明"; shortcut.WorkingDirectory = Environment.CurrentDirectory;//程序所在文件夹,在快捷方式图标点击右键可以看到此属性 shortcut.IconLocation = exePath;//图标,该图标是应用程序的资源文件 //shortcut.Hotkey = "CTRL+SHIFT+W";//热键,发现没作用,大概需要注册一下 shortcut.WindowStyle = 1; shortcut.Save(); } }
相关文章推荐
- 在ClickOnce应用程序中创建桌面快捷方式
- Android应用程序创建桌面快捷方式
- C#创建桌面快捷方式
- Ubuntu应用程序创建桌面快捷方式
- .NET 应用程序中创建桌面快捷方式
- C# 创建快捷方式,如建立桌面和程序夹的快捷方式链接,并且上ALL USERS级别
- [置顶] android,解决手动创建的桌面快捷方式无法跳转到制定的activity的问题,提示未安装应用程序
- 创建桌面快捷方式+设置开机启动代码[C#、WinForm]
- Android 为应用程序创建桌面快捷方式
- C#创建桌面快捷方式 和 开机启动
- android 为应用程序创建桌面快捷方式技巧分享
- Linux系统:Ubuntu下如何在桌面创建一个应用程序的“快捷方式”?
- ubuntu 在桌面上创建应用程序图标(快捷方式)
- [No000074]C#创建桌面快捷方式
- Android应用程序创建桌面快捷方式
- wince c# 创建桌面快捷方式 自动启动 只运行一次 全屏显示
- C#实现创建桌面快捷方式与添加网页到收藏夹的示例
- Linux Mint创建应用程序菜单及桌面快捷方式
- Android 为应用程序中的任意Activity创建桌面快捷方式
- Ubuntu应用程序创建桌面快捷方式