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

首頁 > 編程 > C# > 正文

C#實現在啟動目錄創建快捷方式的方法

2020-01-24 01:28:51
字體:
來源:轉載
供稿:網友

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

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

/// <summary>/// 將文件放到啟動文件夾中開機啟動/// </summary>/// <param name="setupPath">啟動程序</param>/// <param name="linkname">快捷方式名稱</param>/// <param name="description">描述</param>public void SetSetupWindowOpenRun(string setupPath, string linkname, string description){ string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "http://" + linkname + ".lnk"; if (System.IO.File.Exists(desktop))  System.IO.File.Delete(desktop); IWshRuntimeLibrary.WshShell shell; IWshRuntimeLibrary.IWshShortcut shortcut; try {  shell = new IWshRuntimeLibrary.WshShell();  shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(desktop);  shortcut.TargetPath = setupPath;//程序路徑  shortcut.Arguments = "";//參數  shortcut.Description = description;//描述  shortcut.WorkingDirectory = System.IO.Path.GetDirectoryName(setupPath);//程序所在目錄  shortcut.IconLocation = setupPath;//圖標     shortcut.WindowStyle = 1;  shortcut.Save(); } catch (Exception ex) {  System.Windows.Forms.MessageBox.Show(ex.Message, "友情提示"); } finally {  shell = null;  shortcut = null; }}

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东平县| 平利县| 甘孜县| 安新县| 津南区| 年辖:市辖区| 西城区| 肇东市| 泊头市| 宁晋县| 普定县| 绥滨县| 苍山县| 陕西省| 竹溪县| 峨山| 宜兰市| 五原县| 汪清县| 石城县| 龙口市| 新民市| 隆尧县| 双江| 雷山县| 九龙坡区| 台南县| 罗源县| 当阳市| 色达县| 望奎县| 绥化市| 开封市| 虞城县| 涞水县| 定安县| 任丘市| 太湖县| 蒙自县| 都安| 定南县|