Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 如何获取internet快捷方式(.URL)的URL?_Vb.net_Url_Desktop Shortcut - Fatal编程技术网

Vb.net 如何获取internet快捷方式(.URL)的URL?

Vb.net 如何获取internet快捷方式(.URL)的URL?,vb.net,url,desktop-shortcut,Vb.net,Url,Desktop Shortcut,我的客户在他的桌面上有一些internet快捷方式(*.url),我想通过VB应用程序获取他们的url,并将其用作变量 知道我该怎么做吗?有一个用于*.lnk和*.appref ms-文件的文件。 但似乎也适用于*.url-文件 从网站上引用: 要检查文件是否为快捷方式并解析快捷方式路径,请 COM库使用Microsoft Shell控件和自动化。这 库被添加到Visual Studio项目的引用中 代码: 是否必须先导入某些内容?您需要添加对COM库Microsoft Shell控件和自动化的

我的客户在他的桌面上有一些internet快捷方式
(*.url)
,我想通过VB应用程序获取他们的url,并将其用作变量

知道我该怎么做吗?

有一个用于
*.lnk
*.appref ms
-文件的文件。
但似乎也适用于
*.url
-文件

从网站上引用:

要检查文件是否为快捷方式并解析快捷方式路径,请 COM库使用Microsoft Shell控件和自动化。这 库被添加到Visual Studio项目的引用中

代码:


是否必须先导入某些内容?您需要添加对COM库Microsoft Shell控件和自动化的引用。
文件。*
路径。*
函数来自
System.IO.
-命名空间
Public Function IsShortcut(strPath As String) As Boolean 
    If Not File.Exists(strPath) Then 
        Return False 
    End If 

    Dim directory As String = Path.GetDirectoryName(strPath) 
    Dim strFile As String = Path.GetFileName(strPath) 

    Dim shell As Shell32.Shell = New Shell32.Shell() 
    Dim folder As Shell32.Folder = shell.NameSpace(directory) 
    Dim folderItem As Shell32.FolderItem = folder.ParseName(strFile) 

    If folderItem IsNot Nothing Then 
        Return folderItem.IsLink 
    End If 

    Return False 
End Function

Public Function ResolveShortcut(strPath As String) As String 
    If IsShortcut(strPath) Then 
        Dim directory As String = Path.GetDirectoryName(strPath) 
        Dim strFile As String = Path.GetFileName(strPath) 

        Dim shell As Shell32.Shell = New Shell32.Shell() 
        Dim folder As Shell32.Folder = shell.NameSpace(directory) 
        Dim folderItem As Shell32.FolderItem = folder.ParseName(strFile) 

        Dim link As Shell32.ShellLinkObject = folderItem.GetLink 

        Return link.Path 
    End If 

    Return String.Empty 
End Function