C#创建桌面快捷方式
//得到桌面文件夹
string DesktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);
FileInfo file = new FileInfo(DesktopPath + "\\快捷方式名称.lnk");
//如果存在则不创建
if (file.Exists)
{
return;
}
IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShellClass();
IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(DesktopPath + "\\\快捷方式名称.lnk");
shortcut.TargetPath = System.Environment.CurrentDirectory + "\\aaa.exe";//程序路径
shortcut.Arguments = "";// 参数
shortcut.Description = "快捷方式名称";
shortcut.WorkingDirectory = System.Environment.CurrentDirectory;//程序所在文件夹,在快捷方式图标点击右键可以看到此属性
//shortcut.IconLocation = @"D:\software\cmpc\zy.exe,0";//图标
//shortcut.Hotkey = "CTRL+SHIFT+Z";//热键
shortcut.WindowStyle = 1;