【发布时间】:2015-07-27 20:22:09
【问题描述】:
我目前正在以编程方式创建快捷方式,但我想知道是否可以在 C# 中以类似方式创建全局快捷方式。
下面是我的代码:
WshShell shell = new WshShell();
string shortcutLocation = "pathToShortcut//Shortcut1.lnk"
IWshShortcut shortcut = shell.CreateShortcut(shortcutLocation);
shortcut.Arguments = "foo bar";
shortcut.Description = "Test Shortcut";
shortcut.TargetPath = "pathToShortcutExe";
shortcut.WorkingDirectory = "pathToWorkingDirectory"
shortcut.Save();
这段代码非常适合为用户创建快捷方式,但我想知道是否有一种方法可以为系统执行此操作。我已经看到全局安装的程序会在所有用户上放置快捷方式,所以我很好奇如何在 C# 中实现这种效果。
【问题讨论】:
标签: c# desktop-shortcut