private Monitor(IntPtr handle) { Handle = handle; var mi = new MONITORINFOEX(); mi.cbSize = Marshal.SizeOf(mi); if (!GetMonitorInfo(handle, ref mi)) { throw new Win32Exception(Marshal.GetLastWin32Error()); } DeviceName = mi.szDevice.ToString(); Bounds = mi.rcMonitor; WorkingArea = mi.rcWork; IsPrimary = (mi.dwFlags & MONITORINFOF_PRIMARY) == MONITORINFOF_PRIMARY; }
private static extern bool GetMonitorInfo(IntPtr hmonitor, ref MONITORINFOEX info);