private static uint GetMonitorCapabilities(PHYSICAL_MONITOR physicalMonitor)
        {
            uint dwMonitorCapabilities, dwSupportedColorTemperatures;

            if (!GetMonitorCapabilities(physicalMonitor.hPhysicalMonitor, out dwMonitorCapabilities, out dwSupportedColorTemperatures))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            return(dwMonitorCapabilities);
        }
        public static double GetMonitorContrast(PHYSICAL_MONITOR physicalMonitor)
        {
            uint dwMinimumContrast, dwCurrentContrast, dwMaximumContrast;

            if (!GetMonitorContrast(physicalMonitor.hPhysicalMonitor, out dwMinimumContrast, out dwCurrentContrast, out dwMaximumContrast))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            return((double)(dwCurrentContrast - dwMinimumContrast) / (double)(dwMaximumContrast - dwMinimumContrast));
        }
        public static double GetMonitorBrightness(PHYSICAL_MONITOR physicalMonitor)
        {
            uint dwMinimumBrightness, dwCurrentBrightness, dwMaximumBrightness;

            if (!GetMonitorBrightness(physicalMonitor.hPhysicalMonitor, out dwMinimumBrightness, out dwCurrentBrightness, out dwMaximumBrightness))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            return((double)(dwCurrentBrightness - dwMinimumBrightness) / (double)(dwMaximumBrightness - dwMinimumBrightness));
        }
        public static void SetMonitorContrast(PHYSICAL_MONITOR physicalMonitor, double contrast)
        {
            uint dwMinimumContrast, dwCurrentContrast, dwMaximumContrast;

            if (!GetMonitorContrast(physicalMonitor.hPhysicalMonitor, out dwMinimumContrast, out dwCurrentContrast, out dwMaximumContrast))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            if (!SetMonitorContrast(physicalMonitor.hPhysicalMonitor, (uint)(dwMinimumContrast + (dwMaximumContrast - dwMinimumContrast) * contrast)))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
        }
        public static void SetMonitorBrightness(PHYSICAL_MONITOR physicalMonitor, double brightness)
        {
            uint dwMinimumBrightness, dwCurrentBrightness, dwMaximumBrightness;

            if (!GetMonitorBrightness(physicalMonitor.hPhysicalMonitor, out dwMinimumBrightness, out dwCurrentBrightness, out dwMaximumBrightness))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            if (!SetMonitorBrightness(physicalMonitor.hPhysicalMonitor, (uint)(dwMinimumBrightness + (dwMaximumBrightness - dwMinimumBrightness) * brightness)))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
        }
        public static PHYSICAL_MONITOR[] GetPhysicalMonitors(IntPtr hMonitor)
        {
            uint dwNumberOfPhysicalMonitors;

            if (!GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, out dwNumberOfPhysicalMonitors))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            PHYSICAL_MONITOR[] physicalMonitorArray = new PHYSICAL_MONITOR[dwNumberOfPhysicalMonitors];
            if (!GetPhysicalMonitorsFromHMONITOR(hMonitor, dwNumberOfPhysicalMonitors, physicalMonitorArray))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            return(physicalMonitorArray);
        }
 public static bool GetContrastSupport(PHYSICAL_MONITOR physicalMonitor)
 {
     return((GetMonitorCapabilities(physicalMonitor) & MC_CAPS_CONTRAST) != 0);
 }
 public static bool GetBrightnessSupport(PHYSICAL_MONITOR physicalMonitor)
 {
     return((GetMonitorCapabilities(physicalMonitor) & MC_CAPS_BRIGHTNESS) != 0);
 }