国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#實現(xiàn)在啟動目錄創(chuàng)建快捷方式的方法

2019-10-29 21:38:58
字體:
供稿:網(wǎng)友

這篇文章主要介紹了C#實現(xiàn)在啟動目錄創(chuàng)建快捷方式的方法,涉及C#快捷方式的創(chuàng)建技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了C#實現(xiàn)在啟動目錄創(chuàng)建快捷方式的方法。分享給大家供大家參考。具體如下:

添加引用,選擇 COM 選項卡并選擇 Windows Script Host Object Model

 

 
  1. /// <summary> 
  2. /// 將文件放到啟動文件夾中開機(jī)啟動 
  3. /// </summary> 
  4. /// <param name="setupPath">啟動程序</param> 
  5. /// <param name="linkname">快捷方式名稱</param> 
  6. /// <param name="description">描述</param> 
  7. public void SetSetupWindowOpenRun(string setupPath, string linkname, string description) 
  8. string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "//" + linkname + ".lnk"; 
  9. if (System.IO.File.Exists(desktop)) 
  10. System.IO.File.Delete(desktop); 
  11. IWshRuntimeLibrary.WshShell shell; 
  12. IWshRuntimeLibrary.IWshShortcut shortcut; 
  13. try 
  14. shell = new IWshRuntimeLibrary.WshShell(); 
  15. shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(desktop); 
  16. shortcut.TargetPath = setupPath;//程序路徑 
  17. shortcut.Arguments = "";//參數(shù) 
  18. shortcut.Description = description;//描述 
  19. shortcut.WorkingDirectory = System.IO.Path.GetDirectoryName(setupPath);//程序所在目錄 
  20. shortcut.IconLocation = setupPath;//圖標(biāo)  
  21. shortcut.WindowStyle = 1; 
  22. shortcut.Save(); 
  23. catch (Exception ex) 
  24. System.Windows.Forms.MessageBox.Show(ex.Message, "友情提示"); 
  25. finally 
  26. shell = null
  27. shortcut = null

希望本文所述對大家的C#程序設(shè)計有所幫助。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 齐齐哈尔市| 东海县| 龙泉市| 武强县| 秭归县| 玛多县| 饶平县| 深水埗区| 南昌市| 霸州市| 灌云县| 平利县| 冀州市| 深泽县| 离岛区| 西乌珠穆沁旗| 洛阳市| 交口县| 新化县| 汕尾市| 阜南县| 台南市| 隆安县| 青海省| 河南省| 江油市| 长顺县| 丰镇市| 交城县| 改则县| 奉化市| 景谷| 呈贡县| 兴山县| 固始县| 永嘉县| 张家界市| 乐东| 孝义市| 云龙县| 凤山县|