Here is my implimentation of the same code..
#! perl -slw
use strict;
use Win32::API;
my $hProcess = getCurrentProcess();
my $cnt=getProcessHandleCount($hProcess);
print "handle count=$cnt\n";
###############
sub getCurrentProcess{
my $GetCurrentProcess = new Win32::API("Kernel32", "GetCurrentProc
+ess", [], 'N') || return $^E;
my $hProcess=$GetCurrentProcess->Call();
return $hProcess;
}
###############
sub getProcessHandleCount{
my $hProcess = shift;
print "hProcess=$hProcess\n";
my $GetProcessHandleCount = new Win32::API("Kernel32", "GetProcess
+HandleCount", ['N','P'], 'N') || return $^E;
my $rtn=' 'x12;
my $ok=$GetProcessHandleCount->Call( $hProcess,$rtn);
my $count=unpack("II", $rtn);
return $count;
}
|