Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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


Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...