Results 1 to 4 of 4

Thread: How to get the HWND or the Window Caption of all open apps? (SOLVED)

  1. #1

    Thread Starter
    Hyperactive Member D12Bit's Avatar
    Join Date
    Oct 2000
    Location
    Guatemala
    Posts
    373

    Thumbs up How to get the HWND or the Window Caption of all open apps? (SOLVED)

    I need to know on certain times what is open and some to close others to minimize...but as a start I need to get the HWNDs and/or the Windows caption ...this is for running it at remote stations...

    Some are W9x others are Me, W2000 and XP...

    any help on this I'll appreciate it...TIA
    Last edited by D12Bit; Aug 8th, 2002 at 03:12 PM.
    "Who Dares Wins" - "Quien se Arriesga Gana"
    Mail me at:

  2. #2
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352
    Taken straight from the API-GUIDE(a very useful tool):

    VB Code:
    1. 'Add this code to a form
    2. Private Sub Form_Load()
    3.     'KPD-Team 2000
    4.     'URL: [url]http://www.allapi.net/[/url]
    5.     'E-Mail: [email][email protected][/email]
    6.     'Set the form's graphics mode to persistent
    7.     Me.AutoRedraw = True
    8.     'call the Enumwindows-function
    9.     EnumWindows AddressOf EnumWindowsProc, ByVal 0&
    10. End Sub
    11. 'Add this code to a module
    12. Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean
    13. Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    14. Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
    15. Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
    16.     Dim sSave As String, Ret As Long
    17.     Ret = GetWindowTextLength(hwnd)
    18.     sSave = Space(Ret)
    19.     GetWindowText hwnd, sSave, Ret + 1
    20.     Form1.Print Str$(hwnd) + " " + sSave
    21.     'continue enumeration
    22.     EnumWindowsProc = True
    23. End Function

  3. #3

    Thread Starter
    Hyperactive Member D12Bit's Avatar
    Join Date
    Oct 2000
    Location
    Guatemala
    Posts
    373
    Thanks!...

    Worked like a charm!
    "Who Dares Wins" - "Quien se Arriesga Gana"
    Mail me at:

  4. #4
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352
    No Problem. ALLAPI.net is where you get the API-GUIDE; it is great for simple API functions and learning purposes.

    Joe

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