Results 1 to 2 of 2

Thread: how do i retrieve a list of all current runing applications

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2001
    Posts
    1
    i would like to display alist of all runing applications (like the one shown when pressing ctrl-alt-del) so i can use the names for controling those applications with FindWindow api.
    thanks, nino

  2. #2
    Guest
    Use the EnumWindows function.

    Add to a Module.
    Code:
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
    Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
    
    Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
        Dim Length As Long
        Dim sName As String
        Dim Temp As String
        Static iCount As Integer
        
        iCount = iCount + 1
        Length = GetWindowTextLength(hwnd) + 1
        
        If Length > 1 Then
          sName = Space(Length)
          GetWindowText hwnd, sName, Length
          Debug.Print Left(sName, Length - 1)
        End If
        
        EnumWindowsProc = 1
    End Function
    Usage: (Add to a CommandButton in a Form)
    Code:
    EnumWindows AddressOf EnumWindowsProc, 0
    The results will be printed in the Debug window.

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