有没有办法解析适用于最终位于 c:\windows\installer 中的链接的 .lnk 目标?

StackOverflow https://stackoverflow.com/questions/964444

解析 lnk 的常用方法涉及使用 WShell.WshShortcut 或 IShellLink :

var WshShell = WScript.CreateObject("WScript.Shell");
var oShellLink = WshShell.CreateShortcut(strDesktop + "\\some-shortcut.lnk");
WScript.Echo(oShellLink.TargetPath)

但有些链接无法通过这种方式解决:决议最终以 c:\windows\installer\{some-guid}\python_icon.exe 例如。大多数 Office 程序也存在此问题。

CodeProject 有另一种解决方案,通过对 lnk 格式进行逆向工程 http://www.codeproject.com/KB/shell/ReadLnkFile.aspx 但在这些情况下它不起作用。

还有其他办法吗?

c:\Windows\Installer 文件夹是什么?里面放的something_icon.exe 是什么?

有帮助吗?

解决方案

好的,我在这里找到了解决方案: http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/2df18f93-77d8-4217-94a1-6cbe5333a6c4

由于这些 lnk 是 MSI lnk,因此您必须使用 Msi 函数来解析路径:

TCHAR pc [50] = {0};
TCHAR feat [100] = {0};
TCHAR comp [50] = {0};
int b=MsiGetShortcutTarget("Python (command line).lnk",pc,feat,comp);

TCHAR pth [500] = {0};
DWORD chs = 500;
int i = MsiGetComponentPath (pc, comp, pth, &chs);

甲氧基 包含路径。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top