苏飞论坛
标题:
创建桌面快捷方式
[打印本页]
作者:
qq576733600
时间:
2013-6-8 10:04
标题:
创建桌面快捷方式
今天教大家怎么帮自己的程序自动生成桌面快捷方式, 其实非常简单。不啰嗦了。看代码。
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;
shortcut.Save();
作者:
yangying
时间:
2013-6-8 10:14
强烈支持楼主ing……
作者:
bigyoung
时间:
2013-9-18 11:32
好,谢谢楼主
欢迎光临 苏飞论坛 (http://www.sufeinet.com/)
Powered by Discuz! X3.4