I am making headway with my project (and will be sharing as I move forward).
At this time, I have been successful retrieving memory information from a
WinXP system. Below is code that will queries and reports how much memory is
installed on a system. You need Win32::OLE for this to work. Can someone
test this on other Windows system and let me know if it works (or if it dies
what the error message if any is). The next step for memory will be to
identify how much of the total memory is currently being used.
Thanks,
Tal Cohen
use Win32::OLE qw(in with);
$WMI = Win32::OLE->new('WbemScripting.SWbemLocator') || die "Cannot access
WMI on local machine: ", Win32::OLE->LastError;
$Services = $WMI->ConnectServer($host) || die "Cannot access WMI on remote
machine: ", Win32::OLE->LastError;
$ComputerSysSet = $Services->InstancesOf("Win32_PhysicalMemoryArray");
foreach $ComputerSystem (in($ComputerSysSet)) {
$MaxCap = $ComputerSystem->{'MaxCapacity'};
$MemDev = $ComputerSystem->{'MemoryDevices'};
if ($MaxCap < 1 || $MemDev < 1) {
$myError = Win32::OLE->LastError;
print "An error has occured retreiving memory
information:\n";
print " - $myError -\n";
print "The maximum capacity retreived was
$MaxCap\n";
print "The number of memory devices detected was
$MemDev\n";
print "The total memory capacity of a system is
calculated by\n";
print "taking the maximum capacity, and dividing it
by the number\n";
print "of memory devices and then dividing that
number by 1024 (1K)\n";
} else {
$totalMem = $MaxCap / 1024 / $MemDev;
}
print "There is $totalMem MegaBytes of memory on this
system.\n";
}
exit 0;
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm