|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Display device listHi,
I want to have a list of the display devices available on the computer, just like the Settings tab do in the desktop properties... What I need is the DeviceID, it's rectangle(left, top, width, height) and if it's active or not. Is there a built-in function to get these informations in c# using framework 2.0 or must I still use APIs? thanks ThunderMusic I think you are looking for "System.Windows.Forms.Screen.AllScreens" which
gives you a list of screens on the computer. You can then look at each of the screens <Screen> on the list for attributes. There is an example in BOL. Regard, John Show quote "ThunderMusic" <NoSpAmdanlatathotmaildotcom@NoSpAm.com> wrote in message news:uspi4pXvGHA.976@TK2MSFTNGP05.phx.gbl... > Hi, > I want to have a list of the display devices available on the computer, > just like the Settings tab do in the desktop properties... What I need is > the DeviceID, it's rectangle(left, top, width, height) and if it's active > or not. > > Is there a built-in function to get these informations in c# using > framework 2.0 or must I still use APIs? > > thanks > > ThunderMusic > right, but it only displays screens attached to the desktop and I want
inactive ones too, so I can't use this solution... it would have been great tought if it had everything... thanks ThunderMusic Show quote "John J. Hughes II" <n*@invalid.com> wrote in message news:uMjxavXvGHA.1512@TK2MSFTNGP03.phx.gbl... >I think you are looking for "System.Windows.Forms.Screen.AllScreens" which >gives you a list of screens on the computer. You can then look at each of >the screens <Screen> on the list for attributes. There is an example in >BOL. > > Regard, > John > > "ThunderMusic" <NoSpAmdanlatathotmaildotcom@NoSpAm.com> wrote in message > news:uspi4pXvGHA.976@TK2MSFTNGP05.phx.gbl... >> Hi, >> I want to have a list of the display devices available on the computer, >> just like the Settings tab do in the desktop properties... What I need is >> the DeviceID, it's rectangle(left, top, width, height) and if it's active >> or not. >> >> Is there a built-in function to get these informations in c# using >> framework 2.0 or must I still use APIs? >> >> thanks >> >> ThunderMusic >> > > Hello ThunderMusic,
why not to enumerate manually? http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/tree/browse_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 way too complicated and not even sure i'll retrieve the good information, I
prefer using PInvoke... thanks ThunderMusic Show quote "Michael Nemtsev" <nemt***@msn.com> wrote in message news:1799a79b3a6a3c8c88bb50a94ca63@msnews.microsoft.com... > Hello ThunderMusic, > > why not to enumerate manually? > http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/tree/browse_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 > > 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. Show quote "ThunderMusic" <NoSpAmdanlatathotmaildotcom@NoSpAm.com> wrote in message http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/tree/browse_frm/thread/c184a946d989ef9e/d61dc31c79274d9anews:O7va$QYvGHA.4756@TK2MSFTNGP04.phx.gbl... | way too complicated and not even sure i'll retrieve the good information, I | prefer using PInvoke... | | thanks | | ThunderMusic | | "Michael Nemtsev" <nemt***@msn.com> wrote in message | news:1799a79b3a6a3c8c88bb50a94ca63@msnews.microsoft.com... | > Hello ThunderMusic, | > | > why not to enumerate manually? | > Show quote | > | > 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 | > | > | | |
|||||||||||||||||||||||