当前位置:首页 > .NET

C#创建桌面快捷方式

大滑稽12年前 (2014-03-24).NET1609

//得到桌面文件夹 

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;

 

 

扫描二维码推送至手机访问。

版权声明:本文由第★一★次发布,如需转载请注明出处。

本文链接:https://blog.wpers.net/post/56.html

分享给朋友:

“C#创建桌面快捷方式” 的相关文章

Cbo控件数据源绑定

 //Cbo控件数据源绑定DataTable DtType = noteType.GetTypeList("");         …

C#遍历控件的方法

首先,要想遍历,就必须找到你想找的表单里面的所有控件,然后一个个的逐一比对,当找到了你需要的控件的时候,再做你需要的操作。1、foreach方法foreach (Control control in …

Linq读写XML

         private List<News> GetNews(string html)    &n…

修改注册表限制软件使用次数

private void Form1_Load(object sender, System.EventArgs e){RegistryKey RootKey,RegKey; //项名为:HKEY_CURRENT_USER\Software…

C#修改浏览器主页

string key = @"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main";      &n…

C#获得程序集

 //获得程序集System.Reflection.Assembly assem = System.Reflection.Assembly.GetExecutingAssembly();…