How do I get the actual Monitor name? as seen in the resolution dialog

前端 未结 5 2027
旧巷少年郎
旧巷少年郎 2020-11-27 19:31

I am trying to grab the friendly name for the monitors on my system. I am using C#.

I have tried Screen, which just gives me //./DisplayXX.

5条回答
  •  情歌与酒
    2020-11-27 20:08

    From here: Get Exact Monitor/Display/Screen Name

    Well, this question is old, however, as for the sake of google redirects, I suggest my 'WindowsDisplayAPI' library.

    https://www.nuget.org/packages/WindowsDisplayAPI


    Using the library, there are multiple ways to get the display name. The simplest way is:

    foreach (var display in Display.GetDisplays())
    {
        Console.WriteLine(display.DeviceName);
    }
    

    But this is using the old API, if you are sure that your program targets at least Windows Vista, I suggest the following code:

    foreach (var target in DisplayConfig.PathDisplayTarget.GetDisplayTargets())
    {
        Console.WriteLine(target.FriendlyName);
    }
    

提交回复
热议问题