本文介绍了有没有办法解决一个 .lnk 目标,它适用于以 c:\windows\installer 结尾的链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决 lnk 的常用方法包括使用 WShell.WshShortcut 或 IShellLink :

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)

但是有些链接无法通过这种方式解析:例如,解析最终会在 c:\windows\installer\{some-guid}\python_icon.exe 中.大多数 Office 程序也有这个问题.

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

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.

还有什么办法吗?

这是什么 c:\Windows\Installer 文件夹?放入其中的 something_icon.exe 是什么?

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

推荐答案

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

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

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

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 包含路径.

这篇关于有没有办法解决一个 .lnk 目标,它适用于以 c:\windows\installer 结尾的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-12 11:12