Getting my screen name in c #

I know the Screen class, but when I try to use Screen.AllScreens [0] I get something like. \ Device1. Instead, I would like to get my name on the screen, something like HP 24. How can this be done? Thanks to

+2


source to share


4 answers


I think you want the Win32_DesktopMonitor class from the System.Management namespace. I'm not sure which property you want, but try something like this to see what you get:

SelectQuery q = new SelectQuery("SELECT Name, DeviceID, Description FROM Win32_DesktopMonitor");
using(ManagementObjectSearcher mos = new ManagementObjectSearcher(q))
{
    foreach(ManagementObject mo in mos.Get())
    {
        Console.WriteLine("{0}, {1}, {2}",
            mo.Properties["Name"].Value.ToString(),
            mo.Properties["DeviceID"].Value.ToString(),
            mo.Properties["Description"].Value.ToString());
    }
}

      



You can filter by specific device ID if you like with a simple WHERE DeviceID = 'sausage' clause in SQL. Although perhaps with less sausage.

+5


source


Have you tried the DeviceName property? I think I would do Screen.getPrimaryScreen (). DeviceName



http://msdn.microsoft.com/en-us/library/system.windows.forms.screen.devicename.aspx

0


source


I think you might need to use WMI for this. Here is a link fooobar.com/questions/1701909 / ... . Basically you go for something like Win32_DesktopMonitor .

0


source


You may have "TrueFlat Display" HP 24 "or whatever, but as far as windows are concerned, it is almost certainly only referred to as" Plug and Play Monitor "and what it is.

-1


source







All Articles