【发布时间】:2012-02-26 16:31:55
【问题描述】:
我找到了这段代码:
Public Shared Function GetLnkTarget(ByVal lnkPath As String) As String
Dim shl = New Shell32.Shell()
' Move this to class scope
lnkPath = System.IO.Path.GetFullPath(lnkPath)
Dim dir = shl.[NameSpace](System.IO.Path.GetDirectoryName(lnkPath))
Dim itm = dir.Items().Item(System.IO.Path.GetFileName(lnkPath))
Dim lnk = DirectCast(itm.GetLink, Shell32.ShellLinkObject)
Return lnk.Target.Path
End Function
它适用于一些 .lnk 文件,但例如,如果我添加我的 Skype.exe 桌面链接,它会生成:
C:\Windows\Installer\{...}\SkypeIcon.exe
有解决办法吗?
【问题讨论】:
-
嗯,看起来很像您实际上在使用 GetIconLocation() 方法。
-
在这种情况下我的问题意味着什么?不确定它如何解释为什么它适用于某些链接但不适用于其他链接(例如,它不适用于我桌面上的 Skype 链接)