2014-10-02 67 views
-1

我想知道Microsoft的Windows APi Code Pack庫的類庫是否提供了一種直接的方式來迭代Windows資源管理器實例,以檢索每個資源管理器實例的地址欄的當前路徑,簡而言之,我需要獲取一個列表所有通過Explorer.exe實例打開的路徑。使用Windows API Code Pack可以獲取Windows資源管理器的AddresBar路徑嗎?

這是我想檢索文本(從Explorer.exe的所有正在運行的實例)

enter image description here

,如果這是可能使用Windows API Code Pack那麼我沒有任何我不知道代碼來展示我的進度(這是零),我只是要求獲得有關此信息的更好的調查結果,但任何類型的代碼示例都將非常感謝。

如果Windows API Code Pack不能幫助任務,我有什麼替代方案可以實現這一點?也許Microsoft UI automation

PS:我doscovered使用互操作Microsoft Internet Controls檢索的方式,解決在this url解釋,但我真的很感興趣,到學會如何做到這一點使用Windows API Code Pack

+1

*「一個直接的方式來迭代Windows資源管理器實例來檢索每個實例的當前路徑」*和*「我需要獲得一個包含由Explorer.exe實例打開的所有路徑的列表」*非常不同的問題。資源管理器可以打開更多路徑,只是它的工作目錄。這聽起來像一個[XY問題](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem),你可以編輯你的問題,並解釋你正在嘗試做什麼,這「開放路徑列表」可幫助您解決問題? – 2014-10-02 17:54:46

+0

是@Scott Chamberlain也許我沒有正確地表達我的意圖,我編輯了這個問題來添加這個細節:'檢索每個資源管理器實例的地址欄的當前路徑',我的英語不太好,如果它還不清楚請說出來,感謝您的評論 – ElektroStudios 2014-10-02 17:57:18

+0

此鏈接:http://omegacoder.com/?p=63已死 – 2014-12-29 08:42:33

回答

2

這將讓你大部分的途中有,首先,Microsoft Shell Controls and AutomationMicrosoft 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 

有時候它似乎也報告第一個項目被選中。 This might be a better way

+0

這是一個使用Windows API Code Pack?或Micosoft Shell和控件的解決方案,或者? Shell32命名空間在Windows API代碼包中沒有針對我進行過註冊,請您指定它嗎?感謝您的回答! – ElektroStudios 2014-10-02 18:25:10

+0

從**項目 - >參考中的COM選項卡中添加對「Microsoft Shell Controls and Automation」的參考** – Plutonix 2014-10-02 18:28:01

+0

謝謝,但它返回當前目錄中的第一項,而不是在地址欄中寫入的目錄, m測試它有點發現它是否可以幫助檢索地址欄目錄,謝謝 – ElektroStudios 2014-10-02 18:40:11

相關問題