How to check display settings

  • Thread starter Thread starter Steve Long
  • Start date Start date
S

Steve Long

Hello,
is there a native (.NET class) for grabbing the current settings of the
display adaptor in the framework without going to the GetDeviceCaps API
call? They couldn't have missed this could they have?

Thanks for any direction you can give me on this.
Steve
 
Hi Steve,

You can use the System.Management classes and WMI to find out this
information. I have written a sample for you below with the link to (one of)
the class in the WMI documentation.

I hope this helps.
-----------------------

//documentation lin
http://msdn.microsoft.com/library/d...ry/en-us/wmisdk/wmi/win32_videocontroller.asp

//sample code
SelectQuery query = new SelectQuery("Win32_VideoController");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
foreach (ManagementBaseObject envVar in searcher.Get())
{
Console.WriteLine(envVar["VideoModeDescription"]);
Console.WriteLine(envVar["AdapterRAM"]);
}
 
Aright, I just knew it had to be in there and that is just about as sweet as
can be. Thank you soooo much.
For anybody else wishing more info on this, to get a list of the strings
that you pass into the envVar["some key"],
use this code inside the foreach loop below that Brian wrote

foreach (PropertyData obj In envVar.Properties)
Console.WriteLine(obj.Name);


It turns out that, for the information I was seeking, I needed to pass in
the "Win32_DesktopMonitor" string instead of "Win32_VideoController"
Awesome set of classes NTL.
Steve
 
Back
Top