Geçerli oda parlaklığına göre Monitör Parlaklığını ayarlamak için küçük bir program kurmaya çalışıyorum. GetMonitorBrightness() Erişim İhlali ile çöküyor
Ben MSDN'den talimatları takip ve bunu ayarlamak:cout << "Legen Sie das Fenster bitte auf den zu steuernden Monitor.\n";
system("PAUSE");
HMONITOR hMon = NULL;
char OldConsoleTitle[1024];
char NewConsoleTitle[1024];
GetConsoleTitle(OldConsoleTitle, 1024);
SetConsoleTitle("CMDWindow7355608");
Sleep(40);
HWND hWnd = FindWindow(NULL, "CMDWindow7355608");
SetConsoleTitle(OldConsoleTitle);
hMon = MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY);
DWORD cPhysicalMonitors;
LPPHYSICAL_MONITOR pPhysicalMonitors = NULL;
BOOL bSuccess = GetNumberOfPhysicalMonitorsFromHMONITOR(
hMon,
&cPhysicalMonitors
);
if(bSuccess)
{
pPhysicalMonitors = (LPPHYSICAL_MONITOR)malloc(
cPhysicalMonitors* sizeof(PHYSICAL_MONITOR));
if(pPhysicalMonitors!=NULL)
{
LPDWORD min = NULL, max = NULL, current = NULL;
GetPhysicalMonitorsFromHMONITOR(hMon, cPhysicalMonitors, pPhysicalMonitors);
HANDLE pmh = pPhysicalMonitors[0].hPhysicalMonitor;
if(!GetMonitorBrightness(pmh, min, current, max))
{
cout << "Fehler: " << GetLastError() << endl;
system("PAUSE");
return 0;
}
//cout << "Minimum: " << min << endl << "Aktuell: " << current << endl << "Maximum: " << max << endl;
system("PAUSE");
}
}
Ancak sorunun: her şey Access Violation while writing at Position 0x00000000
) ile program çöküyor GetMonitorBrightness (kullanmayı deneyin
Hata ayıklamaya çalışırken pPhysicalMonitors'ın kullanmak istediğim monitöre sahip olduğunu gördüm, ancak pPhysicalMonitors[0].hPhysicalMonitor
yalnızca 0x0000000 içeriyor. Bu sorunun bir parçası olabilir mi? çöker böylece
Çok teşekkür ederim, DWORD ve adresler bunu düzeltdi. – DoktorMerlin