您的位置:首页 > 移动开发

C# 创建一个application的桌面快捷方式

2016-12-06 10:48 309 查看
1, 项目中添加一个引用。Project > Add
Reference > COM > Windows
Script Host Object Model.

示例代码:

WshShell shell = new WshShell();

string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
string shotcutName = "alex.lnk";
string shortcutAddress = Path.Combine(desktopPath, shotcutName);
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutAddress);
shortcut.Description = "New shortcut for a Notepad";
//shortcut.Hotkey = "Ctrl+Shift+N";
shortcut.TargetPath = Environment.GetFolderPath(Environment.SpecialFolder.System) + @"\notepad.exe";
shortcut.Save();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: