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

发布于 2024-07-23 05:30:44 字数 656 浏览 7 评论 0 原文

解析 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 是什么?

The usual way to resolve lnk involve using WShell.WshShortcut or IShellLink that way :

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

But there are links that can't be resolved that way : the resolution end up in c:\windows\installer\{some-guid}\python_icon.exe for example. Most Office programs have this issue too.

CodeProject has another solution done by reverse engineering the lnk format http://www.codeproject.com/KB/shell/ReadLnkFile.aspx but it does not works in thoses cases.

Is there any other way ?

What is this c:\Windows\Installer folder ? And what is this something_icon.exe that is put in it ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空城缀染半城烟沙 2024-07-30 05:30:44

好的,我在这里找到了解决方案: 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);

pth 包含路径。

Ok I've found the solution here : http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/2df18f93-77d8-4217-94a1-6cbe5333a6c4

Since these lnk are MSI lnk you have to use Msi functions to resolve the path :

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);

pth contains the path.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文