- 論壇徽章:
- 0
|
回復(fù) #1 zhangkeyijian 的帖子
Using Windows WMI or Powershell. it's very easy to get many
informations about PC, so CPAN provides DBD::WMI module to
to do that.
i.e.: PS C:\> Get-WmiObject Win32_DisplayConfiguration
...
PelsHeight : 768
PelsWidth : 1024
SettingID : GeForce4 440 (64M)
SpecificationVersion : 1025
Install DBD::WMI
C:\>ppm install DBD::WMI
Read docu first
C:\>perldoc DBD::WMI
Sample Code to get display info.:
use strict;
use DBI;
my $dbh = DBI->connect('dbi:WMI:');
my @fields = qw (
BitsPerPel
Caption
Description
DeviceName
DisplayFlags
DisplayFrequency
DitherType
DriverVersion
ICMIntent
ICMMethod
LogPixels
PelsHeight
PelsWidth
SettingID
SpecificationVersion
);
my $wql = "SELECT ". join(", ", @fields). " FROM Win32_DisplayConfiguration";
my $sth = $dbh->prepare($wql);
$sth->execute();
my @ary = $dbh->selectrow_array($sth);
foreach my $cnt (0 .. $#fields) {
print $fields[$cnt], ": ", ($ary[$cnt]) ? $ary[$cnt] : "undef", "\n";
}
exit; |
|