我正在使用 WshShell VS2010 .Net 4 和 ant 创建一个快捷方式,以便能够创建一个引用 AccessRuntinme 然后是我们的应用程序的目标路径。这是我到目前为止没有错误的,直到我运行程序并单击按钮。
private void CreateShortCut64()
{
object shDesktop = (object)"Desktop";
WshShell shell = new WshShell();
string shortcutAddress = (string)shell.SpecialFolders.Item(ref shDesktop) + @"\LinkName.lnk";
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutAddress);
string targetPath64 = "\"C:\\Program Files (x86)\\Microsoft Office\\Office12\\MSACCESS.EXE\" \"C:\\Program Files (x86)\\My Program\\Prog.accdr\"";
shortcut.Description = "Program";
shortcut.Hotkey = "Ctrl+Shift+A";
shortcut.TargetPath = targetPath64;
shortcut.IconLocation = "c:\\Program Files (x86)\\My Program\\" + @"\Prog.ico";
shortcut.Save();
}
如果我省略了对 Access Runtime 的引用并且只将我的程序作为目标,那么上面的示例可以正常工作,但是我希望在通过 Windows 编辑目标时可以正常工作的目标中同时包含这两个。
任何帮助都感激不尽。