示例#1
0
 static extern bool GetMonitorInfo(IntPtr hmon, ref MONITORINFO mi);
示例#2
0
        static MonitorInfo GetMonitorInfo(IntPtr hMonitor)
        {
            MONITORINFO mi = new MONITORINFO();
            mi.size = (uint)Marshal.SizeOf(mi);
            if (!Monitors.GetMonitorInfo(hMonitor, ref mi))
                return null;

            return new MonitorInfo
            {
                Handler = hMonitor,
                IsPrimary = mi.flags != 0,
                DisplayArea = mi.monitor.ToRect(),
                WorkingArea = mi.work.ToRect(),
            };
        }