Results 1 to 5 of 5

Thread: Get all apps that are running

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Location
    Texas
    Posts
    313

    Question

    How can I get every app that is running like everything about it like the handel, name ect...

  2. #2
    Guest
    Here is a program that shows you how to list all the apps running and you can also close them as well: App List and Kill

  3. #3
    New Member
    Join Date
    Aug 2000
    Posts
    8
    Here are two examples that you will probably find useful:

    Program Closer

    Terminator
    -Barcode (Admin/webmaster)
    http://nft.cjb.net
    Visual Studio 6.0 Enterprise SP4

  4. #4
    Guest
    Use the EnumWindows function. Next example will retrieve the Name, Class and hWnd of all the running windows.

    Code for a Module
    Code:
    Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
    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 Buffer As String
        Dim Temp As String
        Dim sClass As String
        Dim icLength As Integer
        Static iCount As Integer
        
        iCount = iCount + 1
        Length = GetWindowTextLength(hwnd) + 1
        sClass = Space(255)
        
        If Length > 1 Then
            Buffer = Space(Length)
            'Get the name
            GetWindowText hwnd, Buffer, Length
            'Get the Class
            icLength = GetClassName(hwnd, sClass, 255)
            'Display the Name, Class and hWnd
            sClass = Left(sClass, icLength)
            Debug.Print Left(Buffer, Length - 1) & " - " & sClass & " - " & hwnd
        End If
        
        EnumWindowsProc = 1
    End Function
    Code for a Form with a CommandButton
    Code:
    Private Sub Command1_Click()
        EnumWindows AddressOf EnumWindowsProc, 0
    End Sub

  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>



    Code:
    'open a std project
    'this project uses a list box (List1) 
    
    'list all running task in list1 with there hwnd
    
    'add a bas module and put this code in it
    '
    Option Explicit
    
    Private Declare Function GetWindow Lib "user32" _
    (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    Private Declare Function GetParent Lib "user32" _
    (ByVal hwnd As Long) 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
    
    Const GW_HWNDFIRST = 0
    Const GW_HWNDNEXT = 2
    
    Public Sub LoadTaskList()
    
        Dim CurrWnd As Long
        Dim Length As Long
        Dim TaskName As String
        Dim Parent As Long
        
        Form1.List1.Clear
        CurrWnd = GetWindow(Form1.hwnd, GW_HWNDFIRST)
        
        While CurrWnd <> 0
        Parent = GetParent(CurrWnd)
        Length = GetWindowTextLength(CurrWnd)
        TaskName = Space$(Length + 1)
        Length = GetWindowText(CurrWnd, TaskName, Length + 1)
        TaskName = Left$(TaskName, Len(TaskName) - 1)
        
        If Length > 0 Then
        If TaskName <> Form1.Caption Then
        Form1.List1.AddItem TaskName & "  " & CurrWnd
        End If
        End If
        CurrWnd = GetWindow(CurrWnd, GW_HWNDNEXT)
        DoEvents
        
            Wend
            
    End Sub
    
    ' put this in the form load event of your form
    
    	Call LoadTaskList
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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