나는 다음과 같은 코드를 사용하여 기본 모니터의 밝기를 얻기 위해 노력 :WINAPI C는 ++
POINT monitorPoint = { 0, 0 };
HANDLE monitor = MonitorFromPoint(monitorPoint, MONITOR_DEFAULTTOPRIMARY);
DWORD minb, maxb, currb;
if (GetMonitorBrightness(monitor, &minb, &currb, &maxb) == FALSE) {
std::cout << GetLastError() << std::endl;
}
을하지만 실패하고 Invalid Parameter
을 의미 GetLastError()
반환 87
.
편집 :는이 같은 EnumDisplayMonitors()
및 GetPhysicalMonitorsFromHMONITOR()
를 사용하여이 문제를 해결하기 위해 관리 :
std::vector<HANDLE> pMonitors;
BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
DWORD npm;
GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, &npm);
PHYSICAL_MONITOR *pPhysicalMonitorArray = new PHYSICAL_MONITOR[npm];
GetPhysicalMonitorsFromHMONITOR(hMonitor, npm, pPhysicalMonitorArray);
for (unsigned int j = 0; j < npm; ++j) {
pMonitors.push_back(pPhysicalMonitorArray[j].hPhysicalMonitor);
}
delete pPhysicalMonitorArray;
return TRUE;
}
// and later inside main simply:
EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, NULL);
// and when I need to change the brightness:
for (unsigned int i = 0; i < pMonitors.size(); ++i) {
SetMonitorBrightness(pMonitors.at(i), newValue);
}
나는이 새로운 문제가 발생 :
나는이 모니터가 내가 가지고 있기 때문에 처리 수EnumDisplayMonitors()
에서
1) 2 모니터. 문제는 단지 내 기본 작품입니다. 이 기본 모니터에 대해서도 작동을 멈 춥니 다 몇 시간 동안 SetMonitorBrightness()
을 사용한 후
0xC0262582: ERROR_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA
2) 나는 다음과 같은 오류 얻을 : 내가 보조 모니터 그래서 뭔가하려고 할 때마다 나는이 오류가
을0xC026258D
당신은 monitor'이'NULL' 또는'INVALID_HANDLE_VALUE'없는 '것을 확인 했습니까? – selbie
GetMonitorCapabilities를 호출하여 MC_CAPS_BRIGHTNESS 플래그를 사용할 수 있는지 확인 했습니까? – selbie
'MonitorFromPoint()'는'HANDLE'이 아닌'HMONITOR'를 리턴합니다. STRICT를 사용하여 컴파일하는 경우 코드가 컴파일되지 않습니다. –