Results 1 to 6 of 6

Thread: [RESOLVED] Getting a list of all windows...

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    Resolved [RESOLVED] Getting a list of all windows...

    Does any one know of a way to get a list of all the programs that are running? I've found some code that allows me to get the Window handler (i think it's called, the big number for each window) & then change that into the window's caption... But is there any way to get a list of all the windows any way?









    Added [RESOLVED] to thread title and green "resolved" checkmark - Hack
    Last edited by Hack; Dec 12th, 2005 at 11:47 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Getting a list of all windows...

    This uses a ListBox to display the running processes.
    VB Code:
    1. 'Place The Code In A Module.   This Is Necessary Because A Callback using The AddressOf Operator
    2. 'Is Used In This Code
    3.  
    4. 'in a module
    5. Public Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
    6.  
    7. Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, _
    8. ByVal lParam As Long) As Long
    9.  
    10. Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
    11. (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    12.  
    13. Public Const MAX_LEN = 260
    14.  
    15. Public Function EnumWinProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
    16.     Dim lRet As Long
    17.     Dim strBuffer As String
    18.    
    19.     If IsWindowVisible(hwnd) Then
    20.         strBuffer = Space(MAX_LEN)
    21.         lRet = GetWindowText(hwnd, strBuffer, Len(strBuffer))
    22.         If lRet Then
    23.             Form1.List1.AddItem Left(strBuffer & "  " & hwnd, lRet)
    24.         End If
    25.     End If
    26.    
    27.     EnumWinProc = 1
    28. End Function
    29.  
    30. 'on a form
    31. Private Sub Command1_Click()
    32. Call EnumWindows(AddressOf EnumWinProc, 0)
    33. End Sub

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    Re: Getting a list of all windows...

    Thanks dude It worked!

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Getting a list of all windows...

    You are welcome.

    If this is resolved, please pull down the Thread Tools menu and click the Mark Thread Resolved button. That will let everyone know that you have your answer.

    Thanks.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    Re: [RESOLVED] Getting a list of all windows...

    oh yeah, sorry, i was just comming back to do that and you had already done it :d

  6. #6
    Lively Member
    Join Date
    Jan 2006
    Posts
    121

    Re: [RESOLVED] Getting a list of all windows...

    anyone converted this to C#?

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