Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for getres.pl

(view source code of getres.pl as plain text)

  1. #! perl
  2.  
  3. # WMI query to list all properties and values of the Win32_DisplayConfiguration class
  4. # This Perl script was generated using the WMI Code Generator, Version 1.30
  5. # http://www.robvanderwoude.com/updates/wmigen.html
  6.  
  7. use Win32::OLE( 'in' );
  8.  
  9. use constant wbemFlagReturnImmediately => 0x10;
  10. use constant wbemFlagForwardOnly       => 0x20;
  11.  
  12. if ( $ARGV[0] ) {
  13. 	$computer = $ARGV[0];
  14. } else {
  15. 	$computer = ".";
  16. }
  17.  
  18. my $objWMIService = Win32::OLE->GetObject( "winmgmts://$computer/root/CIMV2" ) or die "WMI connection failed.\n";
  19. my $colItems = $objWMIService->ExecQuery( "SELECT * FROM Win32_DisplayConfiguration", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly );
  20.  
  21. foreach my $objItem ( in $colItems ) {
  22. 	print "Device Name                    : " . $objItem->{ DeviceName } . "\n";
  23. 	print "Pels Width                     : " . $objItem->{ PelsWidth } . "\n";
  24. 	print "Pels Height                    : " . $objItem->{ PelsHeight } . "\n";
  25. 	print "Bits Per Pel                   : " . $objItem->{ BitsPerPel } . "\n";
  26. 	print "Display Frequency              : " . $objItem->{ DisplayFrequency } . "\n";
  27. 	print "\n";
  28. }
  29.  

page last modified: 2024-04-16; loaded in 0.0069 seconds