Here is some code I'm playing with that SHOULD work, however... I haven't worked out how to properly pack the ProcessEntry structure. Feel free to play with it... you'll notice 2 different attempts at the pack... 2 of many that I have tried...
<code>
use Win32::API;
$CreateToolhelp32Snapshot=new Win32::API("kernel32","CreateToolhelp32Snapshot",[N,N],N);
$ProcessFirst=new Win32::API("kernel32","Process32First",[N,P],N);
$ProcessNext=new Win32::API("kernel32","Process32Next",[N,P],N);
# typedef struct tagPROCESSENTRY32 {
# DWORD dwSize;
# DWORD cntUsage;
# DWORD th32ProcessID;
# DWORD th32DefaultHeapID;
# DWORD th32ModuleID;
# DWORD cntThreads;
# DWORD th32ParentProcessID;
# LONG pcPriClassBase;
# DWORD dwFlags;
# TCHAR szExeFile[MAX_PATH]; # MAX_PATH=260
# DWORD th32MemoryBase;
# DWORD th32AccessKey;
# } PROCESSENTRY32;
$template="LLLLLLLLLA260LL";
$snapshot=$CreateToolhelp32Snapshot->Call(2,0);
#print "Snapshot: $snapshot\n";
if ($snapshot) {
$ProcessEntry=pack($template,0,0,0,0,0,0,0,0,0,' 'x260,0,0);
$result=$ProcessFirst->Call($snapshot,$ProcessEntry);
#print "ProcessFirst: $result\n";
while ($result) {
($size,$usage,$pid,$hid,$mid,$threads,$ppid,$base,$flags,$file,$mem,$akey)=
unpack($template,$ProcessEntry);
# foo;
$ProcessEntry=pack($template,());
$result=$ProcessNext->Call($snapshot,$ProcessEntry);
#print "ProcessFirst: $result\n";
}
}
</code>