Waw... considering PInvoke and and saying System.Management is too
complicated, you have no idea how many Win32 API calls you'll need and how
many unmanaged structures you will have to convert to managed
representation, quite an error prone taks (unless you are just here to ask
for the code).
A simple call to Win32_DesktopMonitor will return all (and precise) info
you like, following is a complete sample which might change your mind
using System;
using System.Management;
public class Program {
public static void Main() {
SelectQuery query = new SelectQuery("SELECT Availability, DeviceID,
ScreenHeight , ScreenWidth FROM Win32_DesktopMonitor");
using(ManagementObjectSearcher searcher = new
ManagementObjectSearcher(query))
{
foreach(ManagementObject mo in searcher.Get())
{
Console.WriteLine("{0}, {1}, {2} - {3}",
mo.Properties["DeviceID"].Value.ToString(),
mo.Properties["Availability"].Value.ToString(), // WMI docs for
possible values 3 is running full power
mo.Properties["ScreenHeight"].Value.ToString(),
mo.Properties["ScreenWidth"].Value.ToString());
}
}
}
Willy.
| way too complicated and not even sure i'll retrieve the good information,
I
| prefer using PInvoke...
|
| thanks
|
| ThunderMusic
|
| | > Hello ThunderMusic,
| >
| > why not to enumerate manually?
| >
http://groups.google.com/group/micr..._frm/thread/c184a946d989ef9e/d61dc31c79274d9a
| >
| > T> Hi,
| > T> I want to have a list of the display devices available on the
| > T> computer, just
| > T> like the Settings tab do in the desktop properties... What I need is
| > T> the
| > T> DeviceID, it's rectangle(left, top, width, height) and if it's active
| > T> or
| > T> not.
| > T> Is there a built-in function to get these informations in c# using
| > T> framework 2.0 or must I still use APIs?
| > T> T> thanks
| > T> T> ThunderMusic
| > T> ---
| > WBR,
| > Michael Nemtsev :: blog:
http://spaces.msn.com/laflour
| >
| > "At times one remains faithful to a cause only because its opponents do
| > not cease to be insipid." (c) Friedrich Nietzsche
| >
| >
|
|