在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