private static bool MonitorEnumProc(IntPtr hMonitor, IntPtr hdcMonitor, NativeMethods.DisplayDevicesMethods.RECT rect, IntPtr dwData) { NativeMethods.DisplayDevicesMethods.MONITORINFO mi = new NativeMethods.DisplayDevicesMethods.MONITORINFO(); if (NativeMethods.DisplayDevicesMethods.GetMonitorInfo(hMonitor, mi)) { Monitors.Screens.Add(new Monitors.Screen( (mi.dwFlags & 1) == 1, // 1 = primary monitor mi.rcMonitor.Left, mi.rcMonitor.Top, Math.Abs(mi.rcMonitor.Right - mi.rcMonitor.Left), Math.Abs(mi.rcMonitor.Bottom - mi.rcMonitor.Top))); } return(true); }
internal static extern bool GetMonitorInfo(IntPtr hmonitor, [In, Out] NativeMethods.DisplayDevicesMethods.MONITORINFO info);