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

GetWindowTheme

関数
ウィンドウに関連付けられたテーマハンドルを取得する。
DLLUXTHEME.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HTHEME GetWindowTheme(
    HWND hwnd
);

パラメーター

名前方向
hwndHWNDin

戻り値の型: HTHEME

各言語での呼び出し定義

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

HTHEME GetWindowTheme(
    HWND hwnd
);
[DllImport("UXTHEME.dll", ExactSpelling = true)]
static extern IntPtr GetWindowTheme(
    IntPtr hwnd   // HWND
);
<DllImport("UXTHEME.dll", ExactSpelling:=True)>
Public Shared Function GetWindowTheme(
    hwnd As IntPtr   ' HWND
) As IntPtr
End Function
' hwnd : HWND
Declare PtrSafe Function GetWindowTheme Lib "uxtheme" ( _
    ByVal hwnd As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetWindowTheme = ctypes.windll.uxtheme.GetWindowTheme
GetWindowTheme.restype = ctypes.c_ssize_t
GetWindowTheme.argtypes = [
    wintypes.HANDLE,  # hwnd : HWND
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('UXTHEME.dll')
GetWindowTheme = Fiddle::Function.new(
  lib['GetWindowTheme'],
  [
    Fiddle::TYPE_VOIDP,  # hwnd : HWND
  ],
  Fiddle::TYPE_INTPTR_T)
#[link(name = "uxtheme")]
extern "system" {
    fn GetWindowTheme(
        hwnd: *mut core::ffi::c_void  // HWND
    ) -> isize;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("UXTHEME.dll")]
public static extern IntPtr GetWindowTheme(IntPtr hwnd);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UXTHEME_GetWindowTheme' -Namespace Win32 -PassThru
# $api::GetWindowTheme(hwnd)
#uselib "UXTHEME.dll"
#func global GetWindowTheme "GetWindowTheme" sptr
; GetWindowTheme hwnd   ; 戻り値は stat
; hwnd : HWND -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "UXTHEME.dll"
#cfunc global GetWindowTheme "GetWindowTheme" sptr
; res = GetWindowTheme(hwnd)
; hwnd : HWND -> "sptr"
; HTHEME GetWindowTheme(HWND hwnd)
#uselib "UXTHEME.dll"
#cfunc global GetWindowTheme "GetWindowTheme" intptr
; res = GetWindowTheme(hwnd)
; hwnd : HWND -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	uxtheme = windows.NewLazySystemDLL("UXTHEME.dll")
	procGetWindowTheme = uxtheme.NewProc("GetWindowTheme")
)

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