Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9091

Re: Windows Task Manager - Get the Application Task Description?

$
0
0

The following will return the exe filename of all the running processes. You should be able to use this as a jumping off point to return more information about the processes.

 

First you need this structure:

 

type processentry32 from structure

  unsignedlong dwsize

  unsignedlong cntusage

  unsignedlong th32processid

  unsignedlong th32defaultheapid

  unsignedlong th32moduleid

  unsignedlong cntthreads

  unsignedlong th32parentprocessid

  unsignedlong pcpriclassbase

  unsignedlong dwflags

  character szexefile[260]

end type

 

Then these external function declarations:

 

Function ulong CreateToolhelp32Snapshot ( &

  ulong dwFlags, ulong th32ProcessID ) Library "kernel32.dll"

Function boolean CloseHandle ( &

  ulong hObject ) Library "kernel32.dll"

Function boolean Process32First ( &

  ulong hSnapshot, Ref processentry32 lppe &

  ) Library "kernel32.dll" Alias For "Process32FirstW"

Function boolean Process32Next ( &

  ulong hSnapshot, Ref processentry32 lppe &

  ) Library "kernel32.dll" Alias For "Process32NextW"

 

Then this code:

 

Constant ULong TH32CS_SNAPPROCESS = 2

PROCESSENTRY32 lstr_pe32

ULong lul_SnapShot

String ls_ExeFile

 

 

lul_SnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)

If lul_SnapShot > 0 Then

  lstr_pe32.dwSize = 36 + (260 * 2)

  If Process32First(lul_SnapShot, lstr_pe32) Then

  Do

  If lstr_pe32.th32ProcessID > 0 Then

  ls_ExeFile = String(lstr_pe32.szExeFile)

  End If

  Loop While Process32Next(lul_SnapShot, lstr_pe32)

  End If

  CloseHandle(lul_SnapShot)

End If


Viewing all articles
Browse latest Browse all 9091

Trending Articles