예제 #1
0
        public static MonitorInfo[] GetMonitors()
        {
            List<MonitorInfo> _monitors = new List<MonitorInfo>();

            MonitorEnumProc _callback = (IntPtr hDesktop, IntPtr hdc, ref RECT pRect, int dwData) =>
            {
                MonitorInfo _info = new MonitorInfo();
                _info.cbSize = Marshal.SizeOf(_info);

                NativeMethods.GetMonitorInfo(hDesktop, ref _info);

                _monitors.Add(_info);

                return true;
            };

            NativeMethods.EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, _callback, 0);

            return _monitors.OrderByDescending(m => m.IsPrimary).ToArray();
        }
예제 #2
0
 internal static extern bool GetMonitorInfo(IntPtr hMonitor, ref MonitorInfo lpmi);