I am currently working on a program that will open running processes (for example a running program) for editing and searching. I was wondering how I would list all of the running processes in a seperate window (not the main window) then make them selectable for opening. Any help is appreciated.

Posted on 2002-02-10 21:12:37 by resistance_is_futile
If you are running under win9x this may help you, but under winNT, 2000, XP you'll have to use EnumProcesses Api.

-- --------------------------------------------------------------------------------

;-------- Shows how to use CreateToolhelp32Snapshot to list processes (Win9x only) ---------

.model flat, stdcall
option casemap:none

include c:\masm32\include\windows.inc
;include c:\masm32\include\masm32.inc

include c:\MASM32\INCLUDE\masm32.inc
include c:\MASM32\INCLUDE\user32.inc

include c:\MASM32\INCLUDE\kernel32.inc

includelib c:\MASM32\LIB\masm32.lib
includelib c:\MASM32\LIB\user32.lib
includelib c:\MASM32\LIB\kernel32.lib
;includelib c:\masm32\lib\masm32.lib


Err db "Erreur !",0

processId dd ?
hSnapshot dd ?


invoke CreateToolhelp32Snapshot, TH32CS_SNAPPROCESS,0
cmp eax,-1
jz err_exit
mov hSnapshot,eax

mov PE.dwSize,SIZEOF PE

invoke Process32First, hSnapshot, addr PE
test eax,eax
jz err_exit


invoke MessageBox,0, addr PE.szExeFile, 0, 0

invoke Process32Next, hSnapshot, addr PE
test eax,eax
jne Rblot

invoke ExitProcess,NULL ; Exits ok, it means all processes were enumerates

invoke MessageBox,0, addr Err ,0, MB_OK
invoke ExitProcess,-1

end start
Posted on 2002-02-10 21:26:37 by Axial
Where would I place the EnumProcesses Api at in this example?
Posted on 2002-02-10 21:36:57 by resistance_is_futile
As far as I know EnumProcesses is just giving you the process Identifiers but you will probably want to display that processes window title and maybe some other information. So I sugest creating a proc wich calls EnumProcesses and gets any info about them you need.
Posted on 2002-02-10 22:48:53 by Quantum
what exactly does enumprocesses do and what is its syntax?
Posted on 2002-02-11 08:52:39 by resistance_is_futile
That information can be found here

it is just giving you the Process id numbers of all running processes at the time you call it.
Posted on 2002-02-12 01:02:23 by Quantum
Look up Toolhelp32 and/or PSAPI and read for yourself before
asking more questions. And don't go use this for anything naughty,
or your post will probably magically disappear :].
Posted on 2002-02-12 09:44:01 by f0dder
why dont you use createprocess or findwindow for your "trainer" or whatever you want to call it, and while youre at it you may want to download win32.hlp.
there is a trillion examples of read and write processmemory all over the web.
either you are completely new to programming in which case i suggest you start with something simple (MessageBoxA)
or you have a severe case of dyslexia.


returns 8 hits, all which appear to be very relevant to what youre doing.


returns 9 hits, and might also be something for you to look at.
Posted on 2002-02-12 09:55:13 by tired
Okay first of all I have already tried looking up enumprocess in MY api reference and there is nothing about it. Second, this isnt for a trainer. I dont even work on those anymore. Tired what you need to do is quit being lazy and get a username instead of typing tired all of the time. Since I AM a newbie, I am trying to program a few easy programs so I can practice at what I am learning. And I already know how to program windows and make message boxes etc. That is easy stuff. What I want to do is list all running processes in a window but i dont know how to LIST THE PROCESSES!! All i know how to do is make the window. Also toolhelp32 does not work in xp and i have xp. What i suggest tired, is you read the question that people ask instead of jumping to conclusions. How do you know if i have win32.hlp or not? I had it as soon as i started programming! Oh and I remember hearing something about these forums being for help?? Maybe its just me who knows..
Posted on 2002-02-12 17:56:08 by resistance_is_futile
Hey guys,

Cool it off a little, we try and keep things friendly here.


Posted on 2002-02-12 19:05:02 by hutch--
Also toolhelp32 does not work in xp and i have xp.

XP is based on the NT kernel, that is why you don't have that dll.

Here is what you need to do:

- check whether user is running Win9x/Me or NT/2K/XP
- if it is the Win9x combo, use the process snapshot as previously detailed
- if it is the NT combo, use EnumProcesses.

There must be a billion examples out there on using these two techniques. I would suggest you avoid the C++ ones, they tend to be a little cryptic, instead check out the VB sources, they could be a lot easier to read and translate.
Posted on 2002-02-12 19:40:35 by sluggy