更新时间:2023-01-31 12:17:35
Joepro 在 他们的回答:
您需要添加对 Windows Scripting Host 的 COM 引用.据我所知,没有原生的 .net 方法可以做到这一点.
You'll need to add a COM reference to Windows Scripting Host. As far as i know, there is no native .net way to do this.
WshShellClass wsh = new WshShellClass();
IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut(
Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\shorcut.lnk") as IWshRuntimeLibrary.IWshShortcut;
shortcut.Arguments = "";
shortcut.TargetPath = "c:\app\myftp.exe";
// not sure about what this is for
shortcut.WindowStyle = 1;
shortcut.Description = "my shortcut description";
shortcut.WorkingDirectory = "c:\app";
shortcut.IconLocation = "specify icon location";
shortcut.Save();
对于 .Net 4.0 及更高版本,将第一行替换为以下内容:
For .Net 4.0 and above, replace the first line with the following:
WshShell wsh = new WshShell();