Jinjinov / Hardware.Info

Battery, BIOS, CPU - processor, storage drive, keyboard, RAM - memory, monitor, motherboard, mouse, NIC - network adapter, printer, sound card - audio card, graphics card - video card. Hardware.Info is a .NET Standard 2.0 library and uses WMI on Windows, /dev, /proc, /sys on Linux and sysctl, system_profiler on macOS.
MIT License
483 stars 77 forks source link

Not all Monitors/Screens returned on Windows #50

Closed sensslen closed 1 year ago

sensslen commented 1 year ago

Library version

11.1.0.1

OS & OS version

OS Name: Microsoft Windows 11 Home OS Version: 10.0.22621 N/A Build 22621

Describe the bug

I got three screens connected, but only one is returned when querying hardwareInfo.MonitorList

To Reproduce

using Hardware.Info;

var hardwareInfo = new HardwareInfo(useAsteriskInWMI: true);
hardwareInfo.RefreshAll();

foreach (var hardware in hardwareInfo.MonitorList)
    Console.WriteLine(hardware);

Steps to reproduce the behavior:

  1. Open Visual Studio and create a command line application targeting .net6
  2. Install the package
  3. Have at least two monitors connected
  4. Paste above code snippet to Program.cs
  5. Run the program

Exceptions (if any)

Expected behavior

All monitors should be shown.

Additional context

I found this https://stackoverflow.com/a/36788720/1199089 stack overflow post that suggests there are two possible origins for dieplays. If I use the second origin on my machine, I get all screens connected.

Jinjinov commented 1 year ago

Thank you for noticing this!

I will look into it as soon as I can get another monitor.

hugener commented 1 year ago

Would it be possible to query Screen information rather than just monitor info? Sort of like this: https://github.com/micdenny/WpfScreenHelper/blob/master/src/WpfScreenHelper/Screen.cs I noticed on my machine if I change resolution, the WMI interface will still report the original values, where the EnumDisplayMonitor API will report correct values

Jinjinov commented 1 year ago

Besides https://github.com/Jinjinov/Hardware.Info/blob/master/Hardware.Info/Components/Monitor.cs there is also some info in https://github.com/Jinjinov/Hardware.Info/blob/master/Hardware.Info/Components/VideoController.cs

If there is some property that you would like to have additionally, take a look at https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-desktopmonitor and https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-videocontroller because I didn't add all the properties that are available.

If there is some property that is not present in those, please tell me which exactly it is and I will see what I can do.

sensslen commented 1 year ago

What I would consider most important is to get all displays listed....

Jinjinov commented 1 year ago

Solved in https://github.com/Jinjinov/Hardware.Info/releases/tag/v11.1.1.0