Win32::ToolHelp - Perl extension for obtaining information about currently executing applications (using the ToolHelp API on Win32)
use Win32::ToolHelp; # --- prints names of all processes my @ps = Win32::ToolHelp::GetProcesses(); foreach my $p (@ps) { print $$p[8], "\n"; } # --- prints names of the modules used by the current process my @ms = Win32::ToolHelp::GetProcessModules($$); foreach my $m (@ms) { print $$m[7], "\n"; } # --- prints name of the current process my @cp = Win32::ToolHelp::GetProcess($$); print $cp[8], "\n"; # --- prints full path to the executable of the current process my @cm = Win32::ToolHelp::GetProcessMainModule($$); print $cm[8], "\n"; # --- prints full path to the executable of the first running perl my @pl = Win32::ToolHelp::SearchProcessMainModule("perl.exe"); print $pl[8], "\n";
The Win32::ToolHelp module provides a Perl interface to the ToolHelp API that is present on Windows 95 or higher or Windows 2000 or higher.
The module exposes functionality for obtaining information about currently executing applications (processes and modules used by the processes).
Retrieves list of all processes currently running on the system. The list is returned as an array or array references. See GetProcess for the description of a nested array (information about a single process).
GetProcess
Retrieves list of all modules currently loaded and used by the processes identified by the process id (pid) passed into. The list is returned as an array or array references. See GetProcessModule for the description of a nested array (information about a single module).
GetProcessModule
Retrieves information about the process identified by the process id (pid) passed into. The information is returned as an array of these scalars:
number of references to the process
identifier of the process
identifier of the default heap for the process
module identifier of the process
number of execution threads started by the process
identifier of the process that created the process being examined
base priority of any threads created by this process
reserved; do not use
path and filename of the executable file for the process
The information is the same as in the structure PROCESSENTRY32 filled by the ToolHelp API functions Process32First and Process32Next.
PROCESSENTRY32
Process32First
Process32Next
Retrieves information about a module of the process identified by the process id (pid) and the module id (mid) passed into. The information is returned as an array of these scalars:
module identifier in the context of the owning process
identifier of the process being examined
global usage count on the module
module usage count in the context of the owning process
base address of the module in the context of the owning process
size, in bytes, of the module
handle to the module in the context of the owning process
string containing the module name
string containing the location (path) of the module
The information is the same as in the structure MODULEENTRY32 filled by the ToolHelp API functions Module32First and Module32Next.
MODULEENTRY32
Module32First
Module32Next
Retrieves information about the main executable module of the process identified by the process id (pid) passed into. The information is returned as an array of scalars. See GetProcessModule for the description of the array.
Retrieves information about the process identified by the process executable name (pname) passed into. The information is returned as an array of scalars. See GetProcess for the description of the array.
Retrieves information about a module of the process identified by the process id (pid) and the module name (m) passed into. The information is returned as an array of scalars. See GetProcessModule for the description of the array.
Retrieves information about the main executable module of the process identified by the process executable name (p) passed into. The information is returned as an array of scalars. See GetProcessModule for the description of the array.
Ferdinand Prantl <prantl@host.sk>
See http://prantl.host.sk/perl/modules/Win32/ToolHelp for the most recent version.
Copyright (c) 2002, Ferdinand Prantl. All rights reserved.
Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Author makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
Win32::Process and Win32::Job.
To install Win32::ToolHelp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Win32::ToolHelp
CPAN shell
perl -MCPAN -e shell install Win32::ToolHelp
For more information on module installation, please visit the detailed CPAN module installation guide.