Results 1 to 5 of 5

Thread: Get window path

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    NJ
    Posts
    10
    How to retrieve a path of opened Windows Explorer window?

  2. #2
    Guest
    Is this what you want?

    Code:
    Private Declare Function GetWindowsDirectory _
    Lib "kernel32" Alias "GetWindowsDirectoryA" _
    (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    
    Private Sub Command1_Click()
    
        Dim strFindWinDir$, WinDir$
        WinDir$ = Space(144)
        strFindWinDir$ = GetWindowsDirectory(WinDir$, 144)
        WinDir$ = Trim(WinDir$)
        MsgBox WinDir$
        
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    NJ
    Posts
    10

    Exclamation

    Hmmm... this code is not actually what am I looking for, but I found it useful, thanx. The thing that I am asking about is how to get the directory that is being viewed in Windows Explorer window; for example, by using window handle I want to be able to see which directory is shown in that particular window.

  4. #4
    Guest
    Sorry for the misunderstanding.

    Code:
    Private Declare Function FindWindow Lib "user32" _
    Alias "FindWindowA" (ByVal lpClassName As String, ByVal _
    lpWindowName As String) As Long
    
    Private Declare Function GetWindowTextLength Lib "user32" _
    Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
    
    Private Declare Function GetWindowText Lib "user32" _
    Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString _
    As String, ByVal cch As Long) As Long
    
    
    Public Function GetWindowTitle(ByVal hwnd As Long) As String
       Dim l As Long
       Dim s As String
    
       l = GetWindowTextLength(hwnd)
       s = Space(l + 1)
    
       GetWindowText hwnd, s, l + 1
    
       GetWindowTitle = Left$(s, l)
    End Function
    
    
    
    Private Sub Command1_Click()
    
        Dim cabinetwclass As Long
        cabinetwclass = FindWindow("cabinetwclass", vbNullString)
        MsgBox GetWindowTitle(cabinetwclass)
    
    End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    NJ
    Posts
    10

    Thumbs up

    Gr8 code, thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width