Retrieving the task list (running apps)

I need to retrive the current task list; When you hit Ctl-Alt-Del in NT it shows a list of applications (as well as other things), this is what I need.

I need a 98/NT solution

Thanks
aulrich
aulrichAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aulrichAuthor Commented:
Edited text of question.
0
Erick37Commented:
"Enumerate All Processes Currently Running"

http://www.thescarms.com/vbasic/RunningProcs.htm

Note: Does not work under NT.
0
Erick37Commented:
"NT Only - Use PSAPI.DLL to get a complete task list and Process Memory Usage"

http://vbaccelerator.com/codelib/taskman/taskman.htm
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

aulrichAuthor Commented:
I don't want a complete list; I want to get the application list.
0
Neal HartmanCommented:
Let me know if I missed anything. You need to add a listbox.



Const WS_MINIMIZE = &H20000000  ' Style bit 'is minimized'
Const GW_HWNDFIRST = 0          ' Get first Window handle
Const GW_HWNDNEXT = 2           ' Get next window handle
Const GWL_STYLE = (-16)         ' Get Window's style bits
Const SW_RESTORE = 9            ' Restore window
Dim IsTask As Long              ' Style bits for normal task
Dim erg As Long

' The following bits will be combined to define properties
' of a 'normal' task top-level window.  Any window with ' these set will be
' included in the list:
Const WS_VISIBLE = &H10000000      ' Window is not hidden
Const WS_BORDER = &H800000         ' Window has a border

' Other bits that are normally set include:
Const WS_CLIPSIBLINGS = &H4000000  ' can clip windows
Const WS_THICKFRAME = &H40000      ' Window has thick border
Const WS_GROUP = &H20000           ' Window is top of group
Const WS_TABSTOP = &H10000         ' Window has tabstop
 

  Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    Private Declare Function GetWindowWord Lib "user32" (ByVal hwnd As Long, ByVal wIndx As Long) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal wIndx As Long) As Long
    Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpSting As String, ByVal nMaxCount As Long) As Long
    Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
 

Sub FindAllApps()


Dim hwCurr As Long
Dim intLen As Long
Dim strTitle As String
' process all top-level windows in master window list
lstApp.Clear
hwCurr = GetWindow(Me.hwnd, GW_HWNDFIRST)  ' get first window
Do While hwCurr  ' repeat for all windows
  If (hwCurr <> Me.hwnd) And TaskWindow(hwCurr) Then
    intLen = GetWindowTextLength(hwCurr) + 1 ' Get length
    strTitle = Space$(intLen) ' Get caption
    intLen = GetWindowText(hwCurr, strTitle, intLen)
    If intLen > 0 Then ' If we have anything, add it
      lstApp.AddItem strTitle
' and let's save the window handle in the itemdata array
      lstApp.ItemData(lstApp.NewIndex) = hwCurr
    End If
  End If
  hwCurr = GetWindow(hwCurr, GW_HWNDNEXT)
Loop
End Sub

Function TaskWindow(hwCurr As Long) As Long
Dim lngStyle As Long
lngStyle = GetWindowLong(hwCurr, GWL_STYLE)
If (lngStyle And IsTask) = IsTask Then TaskWindow = True
End Function
0
aulrichAuthor Commented:
I still get alot of progs I don't want to see in the list.

Here's what I want:
Step1: Windows Boots up
Step2: I load MSWord & and MSExcel

The list should contain ONLY MSWord and MSExcel.

For reference winNT separates these; hit CTRL+ALT+DEL and you will see a tab list of processes and applications.

Thanks
aulrich
0
JimmieTooCommented:
All you have to do is modify rmcquade's code slightly.
Just before the line " lstApp.AddItem strTitle ", add another If condition and search the strTitle string for "Word" or Excel" or whatever you want.  If that condition is satisfied, then add it to the list.

I've done this, it works.  You should consider splitting the points between rmcquade and myself.

Jim
0
aulrichAuthor Commented:
Sorry, the catch is that the apps loaded will not be Necessarily be known; word and excel were just examples.
0
JimmieTooCommented:
aulrich:

There's a logic problem here!  If you don't know what's running, you need the whole list.  If you are looking for specific apps that are running, then you can specify what to search for.  You can't have it both ways.

Jim
0
laurau7Commented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JimmieTooCommented:
aulrich:

There's a logic problem here!  If you don't know what's running, you need the whole list.  If you are looking for specific apps that are running, then you can specify what to search for.  You can't have it both ways.

Jim
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.