|
|
- HMONITOR hMonitor = NULL;
- DWORD cPhysicalMonitors;
- LPPHYSICAL_MONITOR pPhysicalMonitors = NULL;
- DWORD iRet = 0;
- DWORD dwMonitorCapabilities = 0;
- DWORD dwSupportedColorTemperatures;
- // Get the monitor handle.
- hMonitor = MonitorFromWindow(m_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);
-
- UpdateData();
- if (!SetMonitorBrightness(pPhysicalMonitors->hPhysicalMonitor, dwSetBright))
- {
- CString msg;
- DWORD iRet = 0;
- iRet = GetLastError();
- msg.Format(TEXT("Setting failed error code %d"), iRet);
- MessageBox(msg);
- }
- // Close the monitor handles.
- bSuccess = DestroyPhysicalMonitors(
- cPhysicalMonitors,
- pPhysicalMonitors);
- // Free the array.
- free(pPhysicalMonitors);
- }
- }
-
复制代码
|
|