这将为您提供大部分的帮助,首先,在Project -> ReferencesMicrosoft Shell Controls and Automation
中添加 COM 选项卡的引用和Microsoft Internet Controls
来自 COM 选项卡的引用
Imports Shell32
Private exList As New List(Of String) '
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim exShell As New Shell
exList.Clear()
For Each win As ShellBrowserWindow In DirectCast(exShell.Windows, IShellWindows)
thisPath = ""
If TryCast(win.Document, IShellFolderViewDual) IsNot Nothing Then
thisPath = DirectCast(win.Document, IShellFolderViewDual).FocusedItem.Path
ElseIf TryCast(win.Document, ShellFolderView) IsNot Nothing Then
thisPath = DirectCast(win.Document, ShellFolderView).FocusedItem.Path
End If
If String.IsNullOrEmpty(thisPath) = False Then
ExplorerFiles.Add(thisPath)
End If
Next
End Sub
测试输出:
C:\Temp\_test
M:\Books - Non Fiction\Crusades - Iron Men and Saints\01 Iron Men and Saints.mp3
G:\_Video\_Movies
有时它似乎也报告第一个项目被选中。 这可能是更好的方法