#! 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", "GetCurrentProcess", [], 'N') || return $^E; my $hProcess=$GetCurrentProcess->Call(); return $hProcess; } ############### sub getProcessHandleCount{ my $hProcess = shift; print "hProcess=$hProcess\n"; my $GetProcessHandleCount = new Win32::API("Kernel32", "GetProcessHandleCount", ['N','P'], 'N') || return $^E; my $rtn=' 'x12; my $ok=$GetProcessHandleCount->Call( $hProcess,$rtn); my $count=unpack("II", $rtn); return $count; }