cementboot Posted October 26, 2006 Posted October 26, 2006 Hi, I'm trying to get the path of a directory from a Windows Explorer window. So far, I have been able to use API calls to get the handle of a foreground window and determine if it is an explorer window. However, I can't figure out how to get the path of the directory that is currently displayed in that Explorer window. Is this possible to do using Win32 API? Thanks Quote
cementboot Posted October 28, 2006 Author Posted October 28, 2006 Ok, to solve this problem I ended up having to do some COM interop stuff. But it works, so here is the solution I used: 'Add reference to SHDocVw.dll Private Function EnumerateExplorerWindows(ByVal MyHwnd As Integer) As String Dim IEs As New SHDocVw.ShellWindows() Dim IE As SHDocVw.InternetExplorer For Each IE In IEs Try If IE.HWND = MyHwnd Then Dim u As New Uri(IE.LocationURL) Console.WriteLine("My Path Is: " & u.LocalPath) Return u.LocalPath End If Catch ex As Exception End Try Next End Function Quote
Recommended Posts