![](/img/trans.png)
[英]How can I redirect stdout to some visible display in a Windows Application?
[英]How can I change the “Dim the display” and “Dimming display brightness” setting (Windows) from wihin my application?
我的應用程序已經能夠設置顯示器應關閉的超時時間,以及設置全部時間,並且通常還可以設置當前亮度。 Windows具有一項附加功能,該功能可在一段時間后使顯示變暗(高級電源使用方案設置中的“在之后變暗顯示”和“顯示變暗亮度”)。
有誰知道如何在我的應用程序(它是C / C ++應用程序)中查詢/設置“之后的調暗顯示”和“顯示調暗亮度”設置-如果可能的話,可以使用“純” Windows API?
非常感謝。 您的Willi K.
羅恩向我指出了正確的方向。 以下代碼示例顯示,應用程序如何控制背光何時應調暗至特定的亮度級別(已省略了錯誤檢查等,以使代碼更易於理解)。
#include <iniitguid.h> // Seems to be uncluded before Windows.h for some reason...
#include <windows.h>
#include <powrprof.h>
static const GUID GuidPwrVideoIf = GUID_VIDEO_SUBGROUP;
static const GUID GuidPwrDimTimeout = GUID_VIDEO_DIM_TIMEOUT;
static const GUID GuidPwrDimBrightness = GUID_DEVICE_POWER_POLICY_VIDEO_DIM_BRIGHTNESS;
void setBacklightDimming(DWORD timeOut, DWORD dimmedBrightness)
{
DWORD ret;
GUID *pGuidPwrActiveSheme;
// Attach to the active power scheme
ret = PowerGetActiveScheme(NULL, &pGuidPwrActiveSheme);
// Set the timeout that will elapse before the display will dim
ret = PowerWriteDCValueIndex(NULL, pGuidPwrActiveSheme, &GuidPwrVideoIf, &GuidPwrDimTimeout, timeOut);
// Set the dimmed brightness level
PowerWriteDCValueIndex(NULL, pGuidPwrActiveSheme, &GuidPwrVideoIf, &GuidPwrDimBrightness, dimmedBrightness);
// Apply the new setings immediately
retVal = PowerSetActiveScheme(NULL, pGuidPwrActiveSheme);
// Go on with whatever you want to do...
}
當系統處於“開機狀態”(例如筆記本電腦)時,此代碼示例將更改設置。 要在系統“使用交流電源”時進行設置,只需將PowerWrite DC ValueIndex()替換為PowerWrite AC ValueIndex()。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.