Win32 API 日本語リファレンス
ホームUI.HiDpi › GetProcessDpiAwareness

GetProcessDpiAwareness

関数
指定プロセスのDPI認識レベルを取得する。
DLLapi-ms-win-shcore-scaling-l1-1-1.dll呼出規約winapi対応OSWindows 8.1 以降

シグネチャ

// api-ms-win-shcore-scaling-l1-1-1.dll
#include <windows.h>

HRESULT GetProcessDpiAwareness(
    HANDLE hprocess,   // optional
    PROCESS_DPI_AWARENESS* value
);

パラメーター

名前方向
hprocessHANDLEinoptional
valuePROCESS_DPI_AWARENESS*out

戻り値の型: HRESULT

各言語での呼び出し定義

// api-ms-win-shcore-scaling-l1-1-1.dll
#include <windows.h>

HRESULT GetProcessDpiAwareness(
    HANDLE hprocess,   // optional
    PROCESS_DPI_AWARENESS* value
);
[DllImport("api-ms-win-shcore-scaling-l1-1-1.dll", ExactSpelling = true)]
static extern int GetProcessDpiAwareness(
    IntPtr hprocess,   // HANDLE optional
    out int value   // PROCESS_DPI_AWARENESS* out
);
<DllImport("api-ms-win-shcore-scaling-l1-1-1.dll", ExactSpelling:=True)>
Public Shared Function GetProcessDpiAwareness(
    hprocess As IntPtr,   ' HANDLE optional
    <Out> ByRef value As Integer   ' PROCESS_DPI_AWARENESS* out
) As Integer
End Function
' hprocess : HANDLE optional
' value : PROCESS_DPI_AWARENESS* out
Declare PtrSafe Function GetProcessDpiAwareness Lib "api-ms-win-shcore-scaling-l1-1-1" ( _
    ByVal hprocess As LongPtr, _
    ByRef value As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetProcessDpiAwareness = ctypes.windll.LoadLibrary("api-ms-win-shcore-scaling-l1-1-1.dll").GetProcessDpiAwareness
GetProcessDpiAwareness.restype = ctypes.c_int
GetProcessDpiAwareness.argtypes = [
    wintypes.HANDLE,  # hprocess : HANDLE optional
    ctypes.c_void_p,  # value : PROCESS_DPI_AWARENESS* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('api-ms-win-shcore-scaling-l1-1-1.dll')
GetProcessDpiAwareness = Fiddle::Function.new(
  lib['GetProcessDpiAwareness'],
  [
    Fiddle::TYPE_VOIDP,  # hprocess : HANDLE optional
    Fiddle::TYPE_VOIDP,  # value : PROCESS_DPI_AWARENESS* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "api-ms-win-shcore-scaling-l1-1-1")]
extern "system" {
    fn GetProcessDpiAwareness(
        hprocess: *mut core::ffi::c_void,  // HANDLE optional
        value: *mut i32  // PROCESS_DPI_AWARENESS* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("api-ms-win-shcore-scaling-l1-1-1.dll")]
public static extern int GetProcessDpiAwareness(IntPtr hprocess, out int value);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-shcore-scaling-l1-1-1_GetProcessDpiAwareness' -Namespace Win32 -PassThru
# $api::GetProcessDpiAwareness(hprocess, value)
#uselib "api-ms-win-shcore-scaling-l1-1-1.dll"
#func global GetProcessDpiAwareness "GetProcessDpiAwareness" sptr, sptr
; GetProcessDpiAwareness hprocess, value   ; 戻り値は stat
; hprocess : HANDLE optional -> "sptr"
; value : PROCESS_DPI_AWARENESS* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "api-ms-win-shcore-scaling-l1-1-1.dll"
#cfunc global GetProcessDpiAwareness "GetProcessDpiAwareness" sptr, int
; res = GetProcessDpiAwareness(hprocess, value)
; hprocess : HANDLE optional -> "sptr"
; value : PROCESS_DPI_AWARENESS* out -> "int"
; HRESULT GetProcessDpiAwareness(HANDLE hprocess, PROCESS_DPI_AWARENESS* value)
#uselib "api-ms-win-shcore-scaling-l1-1-1.dll"
#cfunc global GetProcessDpiAwareness "GetProcessDpiAwareness" intptr, int
; res = GetProcessDpiAwareness(hprocess, value)
; hprocess : HANDLE optional -> "intptr"
; value : PROCESS_DPI_AWARENESS* out -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	api_ms_win_shcore_scaling_l1_1_1 = windows.NewLazySystemDLL("api-ms-win-shcore-scaling-l1-1-1.dll")
	procGetProcessDpiAwareness = api_ms_win_shcore_scaling_l1_1_1.NewProc("GetProcessDpiAwareness")
)

// hprocess (HANDLE optional), value (PROCESS_DPI_AWARENESS* out)
r1, _, err := procGetProcessDpiAwareness.Call(
	uintptr(hprocess),
	uintptr(value),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function GetProcessDpiAwareness(
  hprocess: THandle;   // HANDLE optional
  value: Pointer   // PROCESS_DPI_AWARENESS* out
): Integer; stdcall;
  external 'api-ms-win-shcore-scaling-l1-1-1.dll' name 'GetProcessDpiAwareness';
result := DllCall("api-ms-win-shcore-scaling-l1-1-1\GetProcessDpiAwareness"
    , "Ptr", hprocess   ; HANDLE optional
    , "Ptr", value   ; PROCESS_DPI_AWARENESS* out
    , "Int")   ; return: HRESULT
●GetProcessDpiAwareness(hprocess, value) = DLL("api-ms-win-shcore-scaling-l1-1-1.dll", "int GetProcessDpiAwareness(void*, void*)")
# 呼び出し: GetProcessDpiAwareness(hprocess, value)
# hprocess : HANDLE optional -> "void*"
# value : PROCESS_DPI_AWARENESS* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。