Searching...
12:53 AM

Get Window Caption VB6 Code

Code:
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32.dll" () As Long

Function GetCaption(WindowHandle As Long) As String
    On Error Resume Next
    Dim buffer As String, TextLength As Long
        TextLength& = GetWindowTextLength(WindowHandle&)
        buffer$ = String(TextLength&, 0&)
        Call GetWindowText(WindowHandle&, buffer$, TextLength& + 1)
        GetCaption$ = buffer$
                    
End Function

0 comments:

Post a Comment

 
Back to top!