🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: microsoft.public.win32.programmer.kernel
Article #6

Re: Writing UNIX-like ps for WinNT?

#6
From: Stephane
Date: Mon, 09 Nov 1998 00:00
50 lines
2240 bytes
HI

If you have
 access to MSDN, there is a under the hood article on the Performance
counters. That's basically where
all the information you are looking for are stored uptodate by the system.

This article is very clear and comes with the complete code needed to
implement a Process Walker...

Hope it helped.

Stephane
sbarthes@msn.com
Frans Unosson wrote in message <36376A85.3440D91@telia.com>...
>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
>
>
>
Technical Details
Message-ID: <#Q3Vo7FD#GA.220@uppssnewspub04.moswest.msn.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36376A85.3440D91@telia.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 104ed6,5238ca5762a8c88d
X-Google-Attributes: gid104ed6,public
X-Google-Thread: fd2c4,5238ca5762a8c88d
X-Google-Attributes: gidfd2c4,public
X-Google-Thread: f5ca7,5238ca5762a8c88d
X-Google-Attributes: gidf5ca7,public
X-Google-Thread: ff399,5238ca5762a8c88d
X-Google-Attributes: gidff399,public
From: "Stephane" <sbarthes@email.msn.com.nospam>
Subject: Re: Writing UNIX-like ps for WinNT?
Date: 1998/11/09
Message-ID: <#Q3Vo7FD#GA.220@uppssnewspub04.moswest.msn.net>
X-Deja-AN: 410189659
References: <36376A85.3440D91@telia.com>
Newsgroups: microsoft.public.win32.programmer.kernel,microsoft.public.windowsnt.misc,microsoft.public.win32.programmer.tools,borland.public.cppbuilder.winapi
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3