Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用“获取Windows.lnk快捷方式的目标”;从“开始”;目录_C#_Windows 8.1_Shortcut_Wsh_Lnk - Fatal编程技术网

C# 使用“获取Windows.lnk快捷方式的目标”;从“开始”;目录

C# 使用“获取Windows.lnk快捷方式的目标”;从“开始”;目录,c#,windows-8.1,shortcut,wsh,lnk,C#,Windows 8.1,Shortcut,Wsh,Lnk,我试图检索Windows.lnk快捷方式的目标路径,但根据.lnk文件的属性,“目标”不是实际的文件路径: 我使用的是IWSHuntimeLibrary,我访问的快捷方式对象类型为IWshShortcut: WshShell shell = new WshShell(); IWshShortcut link = (IWshShortcut)shell.CreateShortcut(lnkFileName); // This returns "C:\Windows\Installer\{F843

我试图检索Windows.lnk快捷方式的目标路径,但根据.lnk文件的属性,“目标”不是实际的文件路径:

我使用的是IWSHuntimeLibrary,我访问的快捷方式对象类型为IWshShortcut:

WshShell shell = new WshShell();
IWshShortcut link = (IWshShortcut)shell.CreateShortcut(lnkFileName);
// This returns "C:\Windows\Installer\{F843C6A3-224D-4615-94F8-3C461BD9AEA0}\PaintShopProExeIcon.ico"
var targetPath = link.TargetPath;
// This is the same as the "Start in" value in the image above
var workingDir = link.WorkingDirectory;
“link”对象的TargetPath属性不是实际.exe的位置:“C:\Windows\Installer{F843C6A3-224D-4615-94F8-3C461BD9EA0}\PAINTSHOPPROEXECON.ico”

我可以从这个对象获得WorkingDirectory属性,它似乎与上图中快捷方式的“Start in”属性相同。我的问题是,如果TargetPath不是实际的.exe路径,如何获取快捷方式将打开的.exe文件的实际目标路径?这些信息在哪里


本例中的实际目标路径是“C:\Program Files(x86)\Jasc Software Inc\Paint Shop Pro 9\Paint Shop Pro 9.exe”。系统如何知道具体打开“Paint Shop Pro.exe”?

看起来像是一个叫做广告快捷方式的蹩脚把戏。倾向于用来“自我修复”安装,像这样的程序会试图偷回文件关联。或者为尚未安装的程序创建桌面图标。最好的谷歌查询是“msi广告快捷方式”。谢谢。我在找到了一个解决方案,它可以检测广告快捷方式的实际目标路径。