private static string GetMonitorName(string monitorId)
        {
            var displayDevice = new NativeStructs.DISPLAY_DEVICE();

            displayDevice.cb = Marshal.SizeOf(displayDevice);
            NativeMethods.EnumDisplayDevicesA(monitorId, 0, ref displayDevice, 1);

            return(displayDevice.DeviceString);
        }
        public static IEnumerable <NativeStructs.DISPLAY_DEVICE> GetDisplayDevices()
        {
            var displayDevice = new NativeStructs.DISPLAY_DEVICE();

            displayDevice.cb = Marshal.SizeOf(displayDevice);
            for (int i = 0; NativeMethods.EnumDisplayDevicesA(null, i, ref displayDevice, 1); i++)
            {
                if (displayDevice.StateFlags.HasFlag(NativeStructs.DisplayDeviceStateFlags.AttachedToDesktop))
                {
                    yield return(displayDevice);
                }
            }
        }
Beispiel #3
0
 public static extern bool EnumDisplayDevicesA(string lpDevice, int iDevNum, ref NativeStructs.DISPLAY_DEVICE lpDisplayDevice, int dwFlags);