在vb中引用shell32.dll
文件:C:/WINDOWS/system32/SHELL32.dll
名稱:Microsoft Shell Controls And Automation
查詢所有瀏覽器窗口,得到窗口地址,如果是目錄瀏覽,該地址爲file:///形式,若爲網頁,爲http://形式
分別通過document得到對應的目標爲ShellFolderView、HTMLDocument,進一步操作
Private Sub Form_Load()
Dim sh As New Shell
Dim p As ShellFolderView
For Each k In sh.Windows()
Debug.Print Left(k.locationurl, 64)
If Left(k.locationurl, 4) = "file" Then
Set p = k.document
'獲得當前選定的文件項目
For Each z In p.SelectedItems
Debug.Print z
Next
End If
If Left(k.locationurl, 4) = "http" Then
Set d = k.document
Debug.Print " " & d.Title
End If
Next
End Sub