如何从快捷方式 lnk 获取完整的目标字符串 [英] How to get Full Target String from Shortcut lnk

查看:28
本文介绍了如何从快捷方式 lnk 获取完整的目标字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请我尝试从快捷方式文件中获取完整目标.我正在使用以下功能

Please i am trying to get the full target from a shortcut file. I am using the below function

Public Function GetLnkTarget(lnkPath As String) As String
        Dim Obj As Object
        Obj = CreateObject("WScript.Shell")
        Dim Shortcut As Object
        Shortcut = Obj.CreateShortcut(lnkPath)
        Return Shortcut.TargetPath.ToString
End Function

例如,我有一个具有以下目标的快捷方式 .lnk 文件:

For example i have a shortcut .lnk file with the following target:

C:\WINDOWS\system32\wscript.exe /e:VBScript.Encode Folder/skype.exe

当我使用该函数从以下 .lnk 获取目标时D:\Shortcut.lnk

When i use the function to get the target from the following .lnk D:\Shortcut.lnk

GetLnkTarget("D:\Shortcut.lnk")

我得到以下输出

C:\WINDOWS\system32\wscript.exe

因此它不会返回目标的完整字符串,因为输出中缺少/e:VBScript.Encode Folder/skype.exe".

So it does not return the full string of the Target as "/e:VBScript.Encode Folder/skype.exe" is missing from the output.

推荐答案

您需要访问 Shortcut.Arguments 属性.有关快捷方式对象的参考,请参见此处.

You need to access the Shortcut.Arguments property. See here for the reference of the shortcut object.

https://msdn.microsoft.com/en-us/library/f5y78918(v=vs.84).aspx

所以你的代码将是:

Return Shortcut.TargetPath.ToString & " " & Shortcut.Arguments

这篇关于如何从快捷方式 lnk 获取完整的目标字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆