1月72021
获取当前系统 的DPI值
; enum _PROCESS_DPI_AWARENESS
Global Const $PROCESS_DPI_UNAWARE = 0
Global Const $PROCESS_SYSTEM_DPI_AWARE = 1
Global Const $PROCESS_PER_MONITOR_DPI_AWARE = 2
; enum _MONITOR_DPI_TYPE
Global Const $MDT_EFFECTIVE_DPI = 0
Global Const $MDT_ANGULAR_DPI = 1
Global Const $MDT_RAW_DPI = 2
Global Const $MDT_DEFAULT = $MDT_EFFECTIVE_DPI
;~ 96 - 100%
;~ 120 - 125%
_WinAPI_SetProcessDpiAwareness($PROCESS_PER_MONITOR_DPI_AWARE)
Local $aMonitors = _WinAPI_EnumDisplayMonitors()
If Not IsArray($aMonitors) Then Exit MsgBox(0, "", "EnumDisplayMonitors error")
Local $aDPI, $_fake
For $i = 1 To $aMonitors[0][0]
$aDPI = _WinAPI_GetDpiForMonitor($aMonitors[$i][0], $MDT_DEFAULT)
$_fake = IsArray($aDPI) ? MsgBox(0, "Monitor #" & $i, $aDPI[0] & ":" & $aDPI[1]) : MsgBox(0, "Monitor #" & $i, "error")
Next
Exit
Func _WinAPI_SetProcessDpiAwareness($DPIAware)
DllCall("Shcore.dll", "long", "SetProcessDpiAwareness", "int", $DPIAware)
If @error Then Return SetError(1, 0, 0)
EndFunc ;==>_WinAPI_SetProcessDpiAwareness
Func _WinAPI_GetDpiForMonitor($hMonitor, $dpiType)
Local $X, $Y
Local $aRet = DllCall("Shcore.dll", "long", "GetDpiForMonitor", "long", $hMonitor, "int", $dpiType, "uint*", $X, "uint*", $Y)
If @error Or Not IsArray($aRet) Then Return SetError(1, 0, 0)
Local $aDPI[2] = [$aRet[3], $aRet[4]]
Return $aDPI
EndFunc ;==>_WinAPI_GetDpiForMonitor
扫描二维码,在手机上阅读
发表评论
木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!