const PHYSICAL_MONITOR_DESCRIPTION_SIZE = 128; type LPPHYSICAL_MONITOR = ^TPHYSICAL_MONITOR; _PHYSICAL_MONITOR = record hPhysicalMonitor : THandle; szPhysicalMonitorDescription : array[0..PHYSICAL_MONITOR_DESCRIPTION_SIZE] of WCHAR; end; TPHYSICAL_MONITOR = _PHYSICAL_MONITOR;
//获取监视器最大,最小,当前亮度 function GetMonitorBrightness(APhysicalMonitor : THandle; var pdwMinimumBrightness,pdwCurrentBrightness,pdwMaximumBrightness : DWORD):BOOL;stdcall; external 'Dxva2.dll'; //获取监视器最大,最小,当前对比度 function GetMonitorContrast(APhysicalMonitor : THandle; var pdwMinimumContrast,pdwCurrentContrast,pdwMaximumContrast : DWORD):BOOL;stdcall; external 'Dxva2.dll'; //设置监视器亮度 function SetMonitorBrightness(APhysicalMonitor : THandle; dwNewBrightness : DWORD):BOOL;stdcall; external 'Dxva2.dll'; //设置监视器对比度 function SetMonitorContrast(APhysicalMonitor : THandle; dwNewContrast : DWORD):BOOL;stdcall; external 'Dxva2.dll'; //从监视器获取物理监视器 function GetPhysicalMonitorsFromHMONITOR(AMonitor : THandle; dwPhysicalMonitorArraySize : DWORD; pPhysicalMonitorArray : LPPHYSICAL_MONITOR ):BOOL;stdcall; external 'Dxva2.dll';
var h : TPHYSICAL_MONITOR; i : Integer; minC,maxC, currC : DWORD; minB,maxB, currB : DWORD; begin for I := 0 to Screen.MonitorCount - 1 do begin GetPhysicalMonitorsFromHMONITOR(Screen.Monitors[i].Handle, 1, @h); GetMonitorBrightness(h.hPhysicalMonitor, minB, currB, maxB); SetMonitorBrightness(h.hPhysicalMonitor, maxB ); // GetMonitorContrast(h.hPhysicalMonitor, minC, currC, maxC); SetMonitorContrast(h.hPhysicalMonitor, maxC div 2); end; end;
----------------------------------------------
武稀松http://www.raysoftware.cn