首先添加以下引用:COM下Windows Script Host Object Model,然后可以通过以下方法创建快捷方式。
using IWshRuntimeLibrary;
filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShellClass();
IWshRuntimeLibrary.IWshShortcut shortcut =
shell.CreateShortcut(string.Format(CultureInfo.InvariantCulture,
@"{0}\{1}.lnk",
filePath, Application.ProductName)) as IWshRuntimeLibrary.IWshShortcut;
shortcut.TargetPath = Application.ExecutablePath;
shortcut.IconLocation = string.Format(CultureInfo.InvariantCulture, ",0", Application.ExecutablePath);
shortcut.Description = Resources.FormMain.introduce;
shortcut.Save();
using IWshRuntimeLibrary;
filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShellClass();
IWshRuntimeLibrary.IWshShortcut shortcut =
shell.CreateShortcut(string.Format(CultureInfo.InvariantCulture,
@"{0}\{1}.lnk",
filePath, Application.ProductName)) as IWshRuntimeLibrary.IWshShortcut;
shortcut.TargetPath = Application.ExecutablePath;
shortcut.IconLocation = string.Format(CultureInfo.InvariantCulture, ",0", Application.ExecutablePath);
shortcut.Description = Resources.FormMain.introduce;
shortcut.Save();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货