1 回答

TA貢獻1802條經驗 獲得超6個贊
做一些研究,我發現這是創建快捷方式并將其放在文件夾中的更好方法。這里提供了更多細節,代碼(工作并解決問題)是:Startup
WshShell wshShell = new WshShell();
IWshRuntimeLibrary.IWshShortcut shortcut;
string startUpFolderPath =
Environment.GetFolderPath(Environment.SpecialFolder.Startup);
// Create the shortcut
shortcut =
(IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(
startUpFolderPath + "\\" +
Application.ProductName + ".lnk");
shortcut.TargetPath = Application.ExecutablePath;
shortcut.WorkingDirectory = Application.StartupPath;
shortcut.Description = "Launch My Application";
// shortcut.IconLocation = Application.StartupPath + @"\App.ico";
shortcut.Save();
為了能夠使用上述代碼,需要包含命名空間并將 Windows 腳本宿主對象模型引用添加到項目中。IWshRuntimeLibrary
其他參考資料在這里
- 1 回答
- 0 關注
- 124 瀏覽
添加回答
舉報