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

SetThreadDpiHostingBehavior

関数
スレッドのDPIホスティング挙動を設定する。
DLLUSER32.dll呼出規約winapi対応OSWindows 10 以降

シグネチャ

// USER32.dll
#include <windows.h>

DPI_HOSTING_BEHAVIOR SetThreadDpiHostingBehavior(
    DPI_HOSTING_BEHAVIOR value
);

パラメーター

名前方向
valueDPI_HOSTING_BEHAVIORin

戻り値の型: DPI_HOSTING_BEHAVIOR

各言語での呼び出し定義

// USER32.dll
#include <windows.h>

DPI_HOSTING_BEHAVIOR SetThreadDpiHostingBehavior(
    DPI_HOSTING_BEHAVIOR value
);
[DllImport("USER32.dll", ExactSpelling = true)]
static extern int SetThreadDpiHostingBehavior(
    int value   // DPI_HOSTING_BEHAVIOR
);
<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function SetThreadDpiHostingBehavior(
    value As Integer   ' DPI_HOSTING_BEHAVIOR
) As Integer
End Function
' value : DPI_HOSTING_BEHAVIOR
Declare PtrSafe Function SetThreadDpiHostingBehavior Lib "user32" ( _
    ByVal value As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetThreadDpiHostingBehavior = ctypes.windll.user32.SetThreadDpiHostingBehavior
SetThreadDpiHostingBehavior.restype = ctypes.c_int
SetThreadDpiHostingBehavior.argtypes = [
    ctypes.c_int,  # value : DPI_HOSTING_BEHAVIOR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
SetThreadDpiHostingBehavior = Fiddle::Function.new(
  lib['SetThreadDpiHostingBehavior'],
  [
    Fiddle::TYPE_INT,  # value : DPI_HOSTING_BEHAVIOR
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn SetThreadDpiHostingBehavior(
        value: i32  // DPI_HOSTING_BEHAVIOR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USER32.dll")]
public static extern int SetThreadDpiHostingBehavior(int value);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_SetThreadDpiHostingBehavior' -Namespace Win32 -PassThru
# $api::SetThreadDpiHostingBehavior(value)
#uselib "USER32.dll"
#func global SetThreadDpiHostingBehavior "SetThreadDpiHostingBehavior" sptr
; SetThreadDpiHostingBehavior value   ; 戻り値は stat
; value : DPI_HOSTING_BEHAVIOR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USER32.dll"
#cfunc global SetThreadDpiHostingBehavior "SetThreadDpiHostingBehavior" int
; res = SetThreadDpiHostingBehavior(value)
; value : DPI_HOSTING_BEHAVIOR -> "int"
; DPI_HOSTING_BEHAVIOR SetThreadDpiHostingBehavior(DPI_HOSTING_BEHAVIOR value)
#uselib "USER32.dll"
#cfunc global SetThreadDpiHostingBehavior "SetThreadDpiHostingBehavior" int
; res = SetThreadDpiHostingBehavior(value)
; value : DPI_HOSTING_BEHAVIOR -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procSetThreadDpiHostingBehavior = user32.NewProc("SetThreadDpiHostingBehavior")
)

// value (DPI_HOSTING_BEHAVIOR)
r1, _, err := procSetThreadDpiHostingBehavior.Call(
	uintptr(value),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DPI_HOSTING_BEHAVIOR
function SetThreadDpiHostingBehavior(
  value: Integer   // DPI_HOSTING_BEHAVIOR
): Integer; stdcall;
  external 'USER32.dll' name 'SetThreadDpiHostingBehavior';
result := DllCall("USER32\SetThreadDpiHostingBehavior"
    , "Int", value   ; DPI_HOSTING_BEHAVIOR
    , "Int")   ; return: DPI_HOSTING_BEHAVIOR
●SetThreadDpiHostingBehavior(value) = DLL("USER32.dll", "int SetThreadDpiHostingBehavior(int)")
# 呼び出し: SetThreadDpiHostingBehavior(value)
# value : DPI_HOSTING_BEHAVIOR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。