GetVCPFeatureAndVCPFeatureReply fails when called
-
I was trying to get gamma value of monitor using GetVCPFeatureAndVCPFeatureReply[^] to have the default value, and later when using SetVCPFeature[^] to be able to revert to it. But when
GetVCPFeatureAndVCPFeatureReply
is called, it fails. What am I doing wrong? Here is the code test:#include
#include
#include
#include
#include#pragma comment(lib, "Dxva2.lib")
int main() {
// Time to click on a different window to test on multiple monitors
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
HWND hwnd = GetForegroundWindow();HMONITOR hMonitor = NULL; DWORD cPhysicalMonitors; LPPHYSICAL\_MONITOR pPhysicalMonitors = NULL; hMonitor = MonitorFromWindow(hwnd, MONITOR\_DEFAULTTONEAREST); BOOL bSuccess = GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, &cPhysicalMonitors); if (bSuccess) { pPhysicalMonitors = (LPPHYSICAL\_MONITOR)malloc(cPhysicalMonitors \* sizeof(PHYSICAL\_MONITOR)); if (pPhysicalMonitors != NULL) { bSuccess = GetPhysicalMonitorsFromHMONITOR(hMonitor, cPhysicalMonitors, pPhysicalMonitors); if (bSuccess) { DWORD pdwCurrentValue; DWORD pdwMaximumValue; bSuccess = GetVCPFeatureAndVCPFeatureReply(pPhysicalMonitors->hPhysicalMonitor, 0x72, NULL, &pdwCurrentValue, &pdwMaximumValue); if (bSuccess) { std::cout << "Current value: " << pdwCurrentValue << " | MaximumValue: " << pdwMaximumValue; } else { std::cout << "Failed GetVCPFeatureAndVCPFeatureReply" << std::endl; } } else { std::cout << "Failed GetPhysicalMonitorsFromHMONITOR" << std::endl; } DestroyPhysicalMonitors(cPhysicalMonitors, pPhysicalMonitors); free(pPhysicalMonitors); } else { std::cout << "Is null" << std::endl; } } else { std::cout << "Failed GetNumb
-
I was trying to get gamma value of monitor using GetVCPFeatureAndVCPFeatureReply[^] to have the default value, and later when using SetVCPFeature[^] to be able to revert to it. But when
GetVCPFeatureAndVCPFeatureReply
is called, it fails. What am I doing wrong? Here is the code test:#include
#include
#include
#include
#include#pragma comment(lib, "Dxva2.lib")
int main() {
// Time to click on a different window to test on multiple monitors
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
HWND hwnd = GetForegroundWindow();HMONITOR hMonitor = NULL; DWORD cPhysicalMonitors; LPPHYSICAL\_MONITOR pPhysicalMonitors = NULL; hMonitor = MonitorFromWindow(hwnd, MONITOR\_DEFAULTTONEAREST); BOOL bSuccess = GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, &cPhysicalMonitors); if (bSuccess) { pPhysicalMonitors = (LPPHYSICAL\_MONITOR)malloc(cPhysicalMonitors \* sizeof(PHYSICAL\_MONITOR)); if (pPhysicalMonitors != NULL) { bSuccess = GetPhysicalMonitorsFromHMONITOR(hMonitor, cPhysicalMonitors, pPhysicalMonitors); if (bSuccess) { DWORD pdwCurrentValue; DWORD pdwMaximumValue; bSuccess = GetVCPFeatureAndVCPFeatureReply(pPhysicalMonitors->hPhysicalMonitor, 0x72, NULL, &pdwCurrentValue, &pdwMaximumValue); if (bSuccess) { std::cout << "Current value: " << pdwCurrentValue << " | MaximumValue: " << pdwMaximumValue; } else { std::cout << "Failed GetVCPFeatureAndVCPFeatureReply" << std::endl; } } else { std::cout << "Failed GetPhysicalMonitorsFromHMONITOR" << std::endl; } DestroyPhysicalMonitors(cPhysicalMonitors, pPhysicalMonitors); free(pPhysicalMonitors); } else { std::cout << "Is null" << std::endl; } } else { std::cout << "Failed GetNumb
On function call failure, why didn't you call GetLastError, as hinted by the documentation[^]? Also, at the very beginning of the linked page, there is:
The physical monitor configuration functions work using the VESA Monitor Control Command Set (MCCS) standard over an I2C interface. Many monitors don't fully implement that standard; so your use of these commands might result in undefined monitor behavior. We don't recommend using these functions for arbitrary monitors without physically validating that they work as intended.
"In testa che avete, Signor di Ceprano?" -- Rigoletto
-
On function call failure, why didn't you call GetLastError, as hinted by the documentation[^]? Also, at the very beginning of the linked page, there is:
The physical monitor configuration functions work using the VESA Monitor Control Command Set (MCCS) standard over an I2C interface. Many monitors don't fully implement that standard; so your use of these commands might result in undefined monitor behavior. We don't recommend using these functions for arbitrary monitors without physically validating that they work as intended.
"In testa che avete, Signor di Ceprano?" -- Rigoletto
CPallini wrote:
On function call failure, why didn't you call GetLastError, as hinted by the documentation[^]?
I don't know how to use it. C/C++ isn't my main language, and only use it when I have to.
CPallini wrote:
Also, at the very beginning of the linked page, there is:
That is not a problem for my monitor.
-
CPallini wrote:
On function call failure, why didn't you call GetLastError, as hinted by the documentation[^]?
I don't know how to use it. C/C++ isn't my main language, and only use it when I have to.
CPallini wrote:
Also, at the very beginning of the linked page, there is:
That is not a problem for my monitor.
-
I was trying to get gamma value of monitor using GetVCPFeatureAndVCPFeatureReply[^] to have the default value, and later when using SetVCPFeature[^] to be able to revert to it. But when
GetVCPFeatureAndVCPFeatureReply
is called, it fails. What am I doing wrong? Here is the code test:#include
#include
#include
#include
#include#pragma comment(lib, "Dxva2.lib")
int main() {
// Time to click on a different window to test on multiple monitors
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
HWND hwnd = GetForegroundWindow();HMONITOR hMonitor = NULL; DWORD cPhysicalMonitors; LPPHYSICAL\_MONITOR pPhysicalMonitors = NULL; hMonitor = MonitorFromWindow(hwnd, MONITOR\_DEFAULTTONEAREST); BOOL bSuccess = GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, &cPhysicalMonitors); if (bSuccess) { pPhysicalMonitors = (LPPHYSICAL\_MONITOR)malloc(cPhysicalMonitors \* sizeof(PHYSICAL\_MONITOR)); if (pPhysicalMonitors != NULL) { bSuccess = GetPhysicalMonitorsFromHMONITOR(hMonitor, cPhysicalMonitors, pPhysicalMonitors); if (bSuccess) { DWORD pdwCurrentValue; DWORD pdwMaximumValue; bSuccess = GetVCPFeatureAndVCPFeatureReply(pPhysicalMonitors->hPhysicalMonitor, 0x72, NULL, &pdwCurrentValue, &pdwMaximumValue); if (bSuccess) { std::cout << "Current value: " << pdwCurrentValue << " | MaximumValue: " << pdwMaximumValue; } else { std::cout << "Failed GetVCPFeatureAndVCPFeatureReply" << std::endl; } } else { std::cout << "Failed GetPhysicalMonitorsFromHMONITOR" << std::endl; } DestroyPhysicalMonitors(cPhysicalMonitors, pPhysicalMonitors); free(pPhysicalMonitors); } else { std::cout << "Is null" << std::endl; } } else { std::cout << "Failed GetNumb
I'm going to look for other ways to change gamma and brightness as this function has too many limitations on hardware. In the past I used SetDeviceGammaRamp[^] for changing gamma, but now it seems that function shouldn't be used anymore. If anyone has some suggestion, they are welcomed and helpful.