Created
September 27, 2017 13:52
-
-
Save sredna/c294cdf9014e03d8cd6f8bd4a39437ec to your computer and use it in GitHub Desktop.
NSIS ManifestDPIAwareness PerMonitorV2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ManifestDPIAware System ; System DPI on Vista/7/8/8.1/10(<10.1607(AU)) | |
ManifestDPIAwareness "PerMonitorV2,System" ; PMv2 on 10.1703(CU)+, System on 10.1607(AU) with NSIS 3.03+ | |
Page Custom DPIInfoPage | |
Page InstFiles | |
!include nsDialogs.nsh | |
Function DPIInfoPage | |
nsDialogs::Create 1018 | |
Pop $0 | |
${NSD_CreateButton} 0 0 50u 14u "Dump" | |
Pop $0 | |
${NSD_OnClick} $0 CallDumpDPIInfo | |
nsDialogs::CreateControl EDIT ${WS_VISIBLE}|${WS_CHILD}|${ES_MULTILINE}|${ES_READONLY}|${WS_VSCROLL}|${WS_HSCROLL} ${WS_EX_CLIENTEDGE} 1 15u -2 -16u "" | |
Pop $9 | |
Push "" | |
Call CallDumpDPIInfo | |
nsDialogs::Show | |
FunctionEnd | |
Function CallDumpDPIInfo | |
Pop $0 | |
${NSD_SetText} $9 "" | |
StrCpy $R0 Page | |
Call DumpDPIInfo | |
StrCpy $R0 "" | |
FunctionEnd | |
!define DetailPrint "!insertmacro DetailPrint " | |
!macro DetailPrint msg | |
${If} $R0 == "Page" | |
SendMessage $9 ${EM_REPLACESEL} 0 "STR:${msg}$\r$\n" | |
${EndIf} | |
DetailPrint "${msg}" | |
!macroend | |
Function DumpDPIInfo | |
System::Call USER32::GetDpiForSystem()i.r0 | |
${DetailPrint} GetDpiForSystem=$0 | |
System::Call USER32::IsProcessDPIAware()i.r0 | |
${DetailPrint} IsProcessDPIAware=$0 | |
System::Call SHCORE::GetProcessDpiAwareness(p0,*i0r0) | |
${DetailPrint} GetProcessDpiAwareness=$0 | |
System::Call USER32::GetThreadDpiAwarenessContext()i.r0 | |
System::Call USER32::GetAwarenessFromDpiAwarenessContext(ir0)i.r1 | |
IntOp $2 $0 & 0x0f ; ?DPI_AWARENESS? | |
IntOp $3 $0 >> 4 ; 0xf0 = ?PerMonitorV#? | |
${DetailPrint} GetThreadDpiAwarenessContext=$0($1)$2.$3 | |
System::Call USER32::GetWindowDpiAwarenessContext(p$hwndparent)i.r0 | |
System::Call USER32::GetAwarenessFromDpiAwarenessContext(ir0)i.r1 | |
${DetailPrint} GetWindowDpiAwarenessContext=$0($1) | |
System::Call USER32::GetDpiForWindow(i$hWndParent)i.r0 | |
${DetailPrint} GetDpiForWindow=$0 | |
/*System::Call USER32::SetThreadDpiAwarenessContext(i-4)i.r0 | |
${DetailPrint} SetThreadDpiAwarenessContext:Old=$0 | |
System::Call USER32::GetAwarenessFromDpiAwarenessContext(ir0)i.r2 | |
System::Call USER32::GetThreadDpiAwarenessContext()i.r0 | |
System::Call USER32::GetAwarenessFromDpiAwarenessContext(ir0)i.r1 | |
${DetailPrint} GetThreadDpiAwarenessContext=$0($2->$1)*/ | |
FunctionEnd | |
Section "DPI info" | |
Call DumpDPIInfo | |
SectionEnd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment