Windows 设置显示亮度代码【msdn】
原创
©著作权归作者所有:来自51CTO博客作者Tody_Guo的原创作品,请联系作者获取转载授权,否则将追究法律责任
GetPhysicalMonitorsFromHMONITOR function
Microsoft code:
HMONITOR hMonitor = NULL;
DWORD cPhysicalMonitors;
LPPHYSICAL_MONITOR pPhysicalMonitors = NULL;
// Get the monitor handle.
hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY);
// Get the number of physical monitors.
BOOL bSuccess = GetNumberOfPhysicalMonitorsFromHMONITOR(
hMonitor,
&cPhysicalMonitors
);
if (bSuccess)
{
// Allocate the array of PHYSICAL_MONITOR structures.
pPhysicalMonitors = (LPPHYSICAL_MONITOR)malloc(
cPhysicalMonitors* sizeof(PHYSICAL_MONITOR));
if (pPhysicalMonitors != NULL)
{
// Get the array.
bSuccess = GetPhysicalMonitorsFromHMONITOR(
hMonitor, cPhysicalMonitors, pPhysicalMonitors);
// Use the monitor handles (not shown).
// Close the monitor handles.
bSuccess = DestroyPhysicalMonitors(
cPhysicalMonitors,
pPhysicalMonitors);
// Free the array.
free(pPhysicalMonitors);
}
you can use GetMonitorBrightness() to obtain detail max/min brightness before to set brightness.
BOOL GetMonitorBrightness(
__in HANDLE hMonitor,
__out LPDWORD pdwMinimumBrightness,
__out LPDWORD pdwCurrentBrightness,
__out LPDWORD pdwMaximumBrightness
);
SetMonitorBrightness function