使用GetMonitorBrightness()调节monitor亮度 |
尚未結案
|
gaiazhang
一般會員 ![]() ![]() 發表:2 回覆:7 積分:1 註冊:2009-02-09 發送簡訊給我 |
我用的是notbook 灌的是win7系统,想要通过API控制monitor的背光亮度。
下面的代码中,调用GetNumberOfPhysicalMonitorsFromHMONITOR函数返回值0,cPhysicalMonitors中有physical monitor的描述,但physical handle 一直是NULL . 看起来是执行过了,但handle去哪儿了呢?为什么没能传回来? [code cpp] void __fastcall TForm1::Button2Click(TObject *Sender) { BOOL bReturnValue = false; HMONITOR hMonitor = NULL; HWND hwnd = NULL; DWORD cPhysicalMonitors; LPPHYSICAL_MONITOR pPhysicalMonitors = NULL; LPDWORD pdwMonitorCapabilities; LPDWORD pdwSupportedColorTemperatures; // Get the monitor handle. hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY); // Get the number of physical monitors. BOOL bSuccess = GetNumberOfPhysicalMonitorsFromHMONITOR( hMonitor, &cPhysicalMonitors ); //error 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); bSuccess = GetMonitorCapabilities(hMonitor,pdwMonitorCapabilities,pdwSupportedColorTemperatures); // Use the monitor handles (not shown). DWORD nMin = 0, nCur = 0, nMax = 0; bSuccess = GetMonitorBrightness(hMonitor, &nMin, &nCur, &nMax); LightTrackBar->Max =nMax; LightTrackBar->Min =nMin; LightTrackBar->Position = nCur; // Close the monitor handles. bSuccess = DestroyPhysicalMonitors(cPhysicalMonitors, pPhysicalMonitors); // Free the array. free(pPhysicalMonitors); } } } [/code]
------
Gaia 編輯記錄
gaiazhang 重新編輯於 2012-11-18 22:07:40, 註解 無‧
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |