[英]IsProcessDPIAware always returns true
在Visual Studio 2005中創建的默認未修改項目中運行以下命令,將在Vista和Windows 7中顯示“是”消息框。有人知道為什么嗎? IsProcessDPIAware的描述如下: http : //msdn.microsoft.com/zh-cn/library/aa969261( VS.85) .aspx 。
HMODULE hUser32 = LoadLibrary(L"user32.dll");
typedef BOOL (*fnPtr)();
fnPtr IsProcessDPIAware = (fnPtr)GetProcAddress(hUser32, "IsProcessDPIAware");
if(IsProcessDPIAware) {
if(IsProcessDPIAware() == TRUE) {
MessageBox(NULL, L"yes", NULL, MB_OK);
}
else {
MessageBox(NULL, L"no", NULL, MB_OK);
}
}
else {
MessageBox(NULL, L"no fn", NULL, MB_OK);
}
FreeLibrary(hUser32);
如果重要的話,我在vwmare中同時運行Vista和Windows 7。
enabled in your Vista or Windows 7 systems? 在Vista或Windows 7系統中是否啟用了 ? 我不確定,但這可能是IsProcessDPIAware
返回TRUE
的原因。
http://msdn.microsoft.com/zh-CN/library/dd464660.aspx#setting_dpi_by_using_control_panel
不管清單如何,都有三種條件會強制Windows 7中的DPI感知:
請注意,其他兼容性設置都無法更改此設置。 選擇“禁用桌面合成”將在初始化進程時禁用桌面合成,但是在進行了強制DPI感知檢查之后,導致啟動多個實例將導致第一個實例沒有強制DPI感知,但隨后的實例具有強制DPI感知。
DPI感知是通過在TEB-> Win32ClientInfo.CI_flags中設置的標志0x20000000來強制的。 這是在win32k!SetAppCompatFlags中初始化的,一旦gdi32.dll調用NtGdiInit(在運行進程入口點之前執行此初始化),它將被調用。 請注意,在Windows 7的較新版本上,僅在64位版本的TEB中設置此標志。
win32k!SetAppCompatFlags中的實際代碼看起來像
if ( (&threadInfo->dwCompatFlags2 & 0x10000000) || !IsCurrentDesktopComposed() || gbForceDPIAware )
{
w32ProcessInfo = PsGetCurrentProcessWin32Process();
w32ProcessInfo->W32PF_Flags |= 0x20000000;
threadInfo->pClientInfo->CI_flags |= 0x20000000;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.