All,

The problem of how to get info on another process comes up here from time
to time. I had my own incentive to solve the problem (I needed a full path
name, and couldn't get it from anywhere I had access to) so with a little
help from my friends (including, but NOT limited to, Dave Roth, Jenda
Krynicky, and the authors of CygWin), I did my own. It comes in two flavors
(WMI and Windows NT), and it attempts to determine which will work (in that
order). So it SHOULD work on any system with WMI, and any Windows NT
system, whether or not you have WMI (e.g. NT 4.0 without the add-on). It's
theoretically possible to extend this to Non-NT non-WMI systems (i.e. Win95
...), but I haven't got access to such a system to work with.

The interface is:

my $pi = Win32::ProcInfo->new ();

There are two optional arguments: server name (which will Croak unless it
in fact uses the WMI interface), and the names of the interfaces to try
(comma-separated list contining 'WMI' or 'NT'; by default it's "WMI,NT").

my @pids = $pi->ListPids ();

returns all the process IDs in the system, including the "special" ones
(like 0). You can pass a list of PIDs in, and it will return all the input
pids which are currently present in the system. I can't think of a good use
for this, but the GetProcInfo call works the same way, and when I wrote
this part of the code I was bedeviled by the hobgoblin of the small mind.

my @info = $pi->GetProcInfo ();

Returns information on the desired processes (if you pass in PIDs) or on
every process it can find (if not). The return is a list of hash
references, one per process. Each hash contains whatever information I
could figure out how to get (and this depends on whether you're using the
NT or WMI variant, and in the former case which version of NT you're on).
The keys are the WMI keys, even if the NT variant is used.

So here are my terms:

Anyone who wants to be a beta tester should write to me (NOT to the mailing
list) and specify whether you want a CPAN-style kit or a ppm-style kit. The
latter WILL install html help - unfortunately recent ActivePerls don't use
this anymore, but you CAN download it separately. You will need Win32::ODBC
and/or Win32::API. Both come with current ActivePerls, but Win32::API
didn't always.

In return, I promise nothing (I'm not getting paid to do this), but I will
attempt to respond to questions and suggestions. Bugs will be fixed when I
can.

Suggestions for other ways to do the same thing can also be made. I tried
Win32::PerfLib, but that doesn't (as nearly as I can tell) get you things
like the full path name of the program that the process is executing.
Win32::Process does all sorts of things to processes it creates, but I
can't figure out how to have it latch onto a random process and do
something with it. Win32::ProcInfo is partly redundant with both of these,
simply because of the architecture (if I may use the word) of Windows. But
if there's any way to do the _whole_ job with another package or
combination of packages, I'd like to know.

Tom Wyant

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to