1
내 고객은 자신의 바탕 화면에 (*.url)
인터넷 바로 가기가 있으며 VB 응용 프로그램을 통해 해당 URL을 가져 와서 변수로 사용하고 싶습니다.인터넷 바로 가기 URL (.url)을 가져 오는 방법은 무엇입니까?
어떻게하면됩니까?
내 고객은 자신의 바탕 화면에 (*.url)
인터넷 바로 가기가 있으며 VB 응용 프로그램을 통해 해당 URL을 가져 와서 변수로 사용하고 싶습니다.인터넷 바로 가기 URL (.url)을 가져 오는 방법은 무엇입니까?
어떻게하면됩니까?
*.lnk
및 *.appref-ms
- 파일의 경우 sample on MSDN이 있습니다.
그러나 *.url
파일에 대해서도 작동하는 것으로 보입니다. 사이트에서
인용구 :
이 파일이 바로 가기인지 확인하고 바로 가기 경로를 해결하기는 COM 라이브러리 마이크로 소프트 쉘 제어 및 자동화이 사용됩니다. 이 라이브러리는 Visual Studio 프로젝트의 참조에 추가됩니다.
코드 :
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
내가 먼저 뭔가를 가져해야합니까? –
COM 라이브러리 _Microsoft 셸 컨트롤 및 자동화 _에 대한 참조를 추가해야합니다. 'File. *'과'Path. *'함수는'System.IO.' 네임 스페이스에 있습니다. – MatSnow