• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • Last Modified:

Windows Task List

How do obtain the windows task list programatically. I have written a network program to reboot PC's on the lan, send messages etc but I'd like to obtain the task list as well.
Basically I just need the titles of running apps, NOT the title bar text.
0
bh832dm
Asked:
bh832dm
1 Solution
 
david_levineCommented:
Not my code, but give it a try:

This code will loop through all running processes in eiher 95 or NT :

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) AsLong
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
CurrWnd = GetWindow(frm.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
      Debug.Print TaskName & " - " & CurrWnd
        End If
        CurrWnd = GetWindow(CurrWnd, GW_HWNDNEXT)
        DoEvents
    Wend

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now