🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: microsoft.public.win32.programmer.kernel
4 messages
4 total messages Started by Frans Unosson Wed, 28 Oct 1998 00:00
Writing UNIX-like ps for WinNT?
#8
Author: Frans Unosson
Date: Wed, 28 Oct 1998 00:00
32 lines
1917 bytes
Hi!

I'm wondering how to write an executable that snapshots and lists all
active processes
and prints their PIDs, names and CPU times in a console window, rather
like the "ps"
command in UNIX. (Or like the list displayed in the TaskManager in NT).
Something like this:
>ps
PID   CPU    Name
123     12%    someservice.exe
231     1%      notepad.exe

I suppose one could loop for(PID=0;PID<1000;PID++), do a OpenProcess()
on every
possible PID, and if a handle is recieved, print out the PID.
But how can I find out the name of a process with a certain PID?
How can I get the processes current CPU usage?

I would also like to write a "kill"-command, that could terminate a
process given its
PID. The latter is probably easier, just do a OpenProcess(), and then
Terminate()?
(Ugly, but still...)

Maybe someone or some company allready has these commands available for
NT?
Code examples?

Regards
/Frans Unosson
mailto:frans@telia.com
Re: Writing UNIX-like ps for WinNT?
#9
Author: Felix Kasza [MVP]
Date: Wed, 28 Oct 1998 00:00
16 lines
1227 bytes
Frans,

 > executable that snapshots and lists all active processes
 > and prints their PIDs

Search MSDN for EnumProcesses() or PSAPI.DLL.

-- 

Cheers,

Felix.

If you post a reply, kindly refrain from emailing it, too.
Note to spammers: felixk@mvps.org is my real email address.
No anti-spam address here. Just one comment: IN YOUR FACE!
Re: Writing UNIX-like ps for WinNT?
#10
Author: Richard D. Lawson
Date: Wed, 28 Oct 1998 00:00
10 lines
1097 bytes
Frans Unosson wrote in message <36376A85.3440D91@telia.com>...
>
>Maybe someone or some company allready has these commands
>available for NT?

The NT Resource Kit comes with "kill.exe" and "pmon.exe", which already
perform the actions you are seeking to program.

-Richard
Re: Writing UNIX-like ps for WinNT?
#11
Author: Matt Gibson
Date: Thu, 29 Oct 1998 00:00
15 lines
1451 bytes
"Richard D. Lawson" wrote:
> The NT Resource Kit comes with "kill.exe" and "pmon.exe", which already
> perform the actions you are seeking to program.

Also, if you're interested in graphical display at all, "pview" (which comes
with Visual Studio) does both, and even displays the individual threads within a
process.

M

-- 
   "It's the gaps between the rain that count,
     and learning how to live amongst them."
          -- Jeff Noon, _Pixel Juice_
Matt Gibson                          http://www.netgates.co.uk/mbmg001/
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads