Пример #1
0
        /// <summary>
        /// Initializes a new display object.
        /// </summary>
        /// <param name="displayNumber"></param>
        public Display(uint displayNumber)
        {
            Device    = new DISPLAY_DEVICE();
            Mode      = new DEVMODE();
            Device.cb = Marshal.SizeOf(Device);

            if (!NativeMethods.EnumDisplayDevices(null, displayNumber, ref Device, 0))
            {
                throw new ArgumentOutOfRangeException("DisplayNumber", displayNumber, "Number is greater than connected displays.");
            }

            DisplayNumber = displayNumber;

            NativeMethods.EnumDisplaySettings(Device.DeviceName, NativeMethods.ENUM_CURRENT_SETTINGS, ref Mode);

            Name         = Device.DeviceName;
            DeviceString = Device.DeviceString;
            DeviceID     = Device.DeviceID;
            DeviceKey    = Device.DeviceKey;
            DeviceState  = Device.StateFlags;
            DevMode      = Mode.dmFields;
            Orientation  = (Orientations)Mode.dmDisplayOrientation;
        }
Пример #2
0
 public static extern int EnumDisplaySettings(
     string lpszDeviceName, int iModeNum, ref DEVMODE lpDevMode);
Пример #3
0
 public static extern DISP_CHANGE ChangeDisplaySettingsEx(
     string lpszDeviceName, ref DEVMODE lpDevMode, IntPtr hwnd,
     DisplaySettingsFlags dwflags, IntPtr lParam);