0
点赞
收藏
分享

微信扫一扫

Windows 设置显示亮度代码【msdn】

惠特曼 2023-01-24 阅读 102


​​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​​


举报

相关推荐

0 条评论