ホーム › UI.Controls › GetCurrentThemeName
GetCurrentThemeName
関数現在使用中のテーマファイル名・色・サイズの名称を取得する。
シグネチャ
// UXTHEME.dll
#include <windows.h>
HRESULT GetCurrentThemeName(
LPWSTR pszThemeFileName,
INT cchMaxNameChars,
LPWSTR pszColorBuff, // optional
INT cchMaxColorChars,
LPWSTR pszSizeBuff, // optional
INT cchMaxSizeChars
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszThemeFileName | LPWSTR | out |
| cchMaxNameChars | INT | in |
| pszColorBuff | LPWSTR | outoptional |
| cchMaxColorChars | INT | in |
| pszSizeBuff | LPWSTR | outoptional |
| cchMaxSizeChars | INT | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// UXTHEME.dll
#include <windows.h>
HRESULT GetCurrentThemeName(
LPWSTR pszThemeFileName,
INT cchMaxNameChars,
LPWSTR pszColorBuff, // optional
INT cchMaxColorChars,
LPWSTR pszSizeBuff, // optional
INT cchMaxSizeChars
);[DllImport("UXTHEME.dll", ExactSpelling = true)]
static extern int GetCurrentThemeName(
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszThemeFileName, // LPWSTR out
int cchMaxNameChars, // INT
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszColorBuff, // LPWSTR optional, out
int cchMaxColorChars, // INT
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszSizeBuff, // LPWSTR optional, out
int cchMaxSizeChars // INT
);<DllImport("UXTHEME.dll", ExactSpelling:=True)>
Public Shared Function GetCurrentThemeName(
<MarshalAs(UnmanagedType.LPWStr)> pszThemeFileName As System.Text.StringBuilder, ' LPWSTR out
cchMaxNameChars As Integer, ' INT
<MarshalAs(UnmanagedType.LPWStr)> pszColorBuff As System.Text.StringBuilder, ' LPWSTR optional, out
cchMaxColorChars As Integer, ' INT
<MarshalAs(UnmanagedType.LPWStr)> pszSizeBuff As System.Text.StringBuilder, ' LPWSTR optional, out
cchMaxSizeChars As Integer ' INT
) As Integer
End Function' pszThemeFileName : LPWSTR out
' cchMaxNameChars : INT
' pszColorBuff : LPWSTR optional, out
' cchMaxColorChars : INT
' pszSizeBuff : LPWSTR optional, out
' cchMaxSizeChars : INT
Declare PtrSafe Function GetCurrentThemeName Lib "uxtheme" ( _
ByVal pszThemeFileName As LongPtr, _
ByVal cchMaxNameChars As Long, _
ByVal pszColorBuff As LongPtr, _
ByVal cchMaxColorChars As Long, _
ByVal pszSizeBuff As LongPtr, _
ByVal cchMaxSizeChars As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetCurrentThemeName = ctypes.windll.uxtheme.GetCurrentThemeName
GetCurrentThemeName.restype = ctypes.c_int
GetCurrentThemeName.argtypes = [
wintypes.LPWSTR, # pszThemeFileName : LPWSTR out
ctypes.c_int, # cchMaxNameChars : INT
wintypes.LPWSTR, # pszColorBuff : LPWSTR optional, out
ctypes.c_int, # cchMaxColorChars : INT
wintypes.LPWSTR, # pszSizeBuff : LPWSTR optional, out
ctypes.c_int, # cchMaxSizeChars : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('UXTHEME.dll')
GetCurrentThemeName = Fiddle::Function.new(
lib['GetCurrentThemeName'],
[
Fiddle::TYPE_VOIDP, # pszThemeFileName : LPWSTR out
Fiddle::TYPE_INT, # cchMaxNameChars : INT
Fiddle::TYPE_VOIDP, # pszColorBuff : LPWSTR optional, out
Fiddle::TYPE_INT, # cchMaxColorChars : INT
Fiddle::TYPE_VOIDP, # pszSizeBuff : LPWSTR optional, out
Fiddle::TYPE_INT, # cchMaxSizeChars : INT
],
Fiddle::TYPE_INT)#[link(name = "uxtheme")]
extern "system" {
fn GetCurrentThemeName(
pszThemeFileName: *mut u16, // LPWSTR out
cchMaxNameChars: i32, // INT
pszColorBuff: *mut u16, // LPWSTR optional, out
cchMaxColorChars: i32, // INT
pszSizeBuff: *mut u16, // LPWSTR optional, out
cchMaxSizeChars: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("UXTHEME.dll")]
public static extern int GetCurrentThemeName([MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszThemeFileName, int cchMaxNameChars, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszColorBuff, int cchMaxColorChars, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszSizeBuff, int cchMaxSizeChars);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UXTHEME_GetCurrentThemeName' -Namespace Win32 -PassThru
# $api::GetCurrentThemeName(pszThemeFileName, cchMaxNameChars, pszColorBuff, cchMaxColorChars, pszSizeBuff, cchMaxSizeChars)#uselib "UXTHEME.dll"
#func global GetCurrentThemeName "GetCurrentThemeName" sptr, sptr, sptr, sptr, sptr, sptr
; GetCurrentThemeName varptr(pszThemeFileName), cchMaxNameChars, varptr(pszColorBuff), cchMaxColorChars, varptr(pszSizeBuff), cchMaxSizeChars ; 戻り値は stat
; pszThemeFileName : LPWSTR out -> "sptr"
; cchMaxNameChars : INT -> "sptr"
; pszColorBuff : LPWSTR optional, out -> "sptr"
; cchMaxColorChars : INT -> "sptr"
; pszSizeBuff : LPWSTR optional, out -> "sptr"
; cchMaxSizeChars : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "UXTHEME.dll" #cfunc global GetCurrentThemeName "GetCurrentThemeName" var, int, var, int, var, int ; res = GetCurrentThemeName(pszThemeFileName, cchMaxNameChars, pszColorBuff, cchMaxColorChars, pszSizeBuff, cchMaxSizeChars) ; pszThemeFileName : LPWSTR out -> "var" ; cchMaxNameChars : INT -> "int" ; pszColorBuff : LPWSTR optional, out -> "var" ; cchMaxColorChars : INT -> "int" ; pszSizeBuff : LPWSTR optional, out -> "var" ; cchMaxSizeChars : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "UXTHEME.dll" #cfunc global GetCurrentThemeName "GetCurrentThemeName" sptr, int, sptr, int, sptr, int ; res = GetCurrentThemeName(varptr(pszThemeFileName), cchMaxNameChars, varptr(pszColorBuff), cchMaxColorChars, varptr(pszSizeBuff), cchMaxSizeChars) ; pszThemeFileName : LPWSTR out -> "sptr" ; cchMaxNameChars : INT -> "int" ; pszColorBuff : LPWSTR optional, out -> "sptr" ; cchMaxColorChars : INT -> "int" ; pszSizeBuff : LPWSTR optional, out -> "sptr" ; cchMaxSizeChars : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT GetCurrentThemeName(LPWSTR pszThemeFileName, INT cchMaxNameChars, LPWSTR pszColorBuff, INT cchMaxColorChars, LPWSTR pszSizeBuff, INT cchMaxSizeChars) #uselib "UXTHEME.dll" #cfunc global GetCurrentThemeName "GetCurrentThemeName" var, int, var, int, var, int ; res = GetCurrentThemeName(pszThemeFileName, cchMaxNameChars, pszColorBuff, cchMaxColorChars, pszSizeBuff, cchMaxSizeChars) ; pszThemeFileName : LPWSTR out -> "var" ; cchMaxNameChars : INT -> "int" ; pszColorBuff : LPWSTR optional, out -> "var" ; cchMaxColorChars : INT -> "int" ; pszSizeBuff : LPWSTR optional, out -> "var" ; cchMaxSizeChars : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT GetCurrentThemeName(LPWSTR pszThemeFileName, INT cchMaxNameChars, LPWSTR pszColorBuff, INT cchMaxColorChars, LPWSTR pszSizeBuff, INT cchMaxSizeChars) #uselib "UXTHEME.dll" #cfunc global GetCurrentThemeName "GetCurrentThemeName" intptr, int, intptr, int, intptr, int ; res = GetCurrentThemeName(varptr(pszThemeFileName), cchMaxNameChars, varptr(pszColorBuff), cchMaxColorChars, varptr(pszSizeBuff), cchMaxSizeChars) ; pszThemeFileName : LPWSTR out -> "intptr" ; cchMaxNameChars : INT -> "int" ; pszColorBuff : LPWSTR optional, out -> "intptr" ; cchMaxColorChars : INT -> "int" ; pszSizeBuff : LPWSTR optional, out -> "intptr" ; cchMaxSizeChars : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
uxtheme = windows.NewLazySystemDLL("UXTHEME.dll")
procGetCurrentThemeName = uxtheme.NewProc("GetCurrentThemeName")
)
// pszThemeFileName (LPWSTR out), cchMaxNameChars (INT), pszColorBuff (LPWSTR optional, out), cchMaxColorChars (INT), pszSizeBuff (LPWSTR optional, out), cchMaxSizeChars (INT)
r1, _, err := procGetCurrentThemeName.Call(
uintptr(pszThemeFileName),
uintptr(cchMaxNameChars),
uintptr(pszColorBuff),
uintptr(cchMaxColorChars),
uintptr(pszSizeBuff),
uintptr(cchMaxSizeChars),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction GetCurrentThemeName(
pszThemeFileName: PWideChar; // LPWSTR out
cchMaxNameChars: Integer; // INT
pszColorBuff: PWideChar; // LPWSTR optional, out
cchMaxColorChars: Integer; // INT
pszSizeBuff: PWideChar; // LPWSTR optional, out
cchMaxSizeChars: Integer // INT
): Integer; stdcall;
external 'UXTHEME.dll' name 'GetCurrentThemeName';result := DllCall("UXTHEME\GetCurrentThemeName"
, "Ptr", pszThemeFileName ; LPWSTR out
, "Int", cchMaxNameChars ; INT
, "Ptr", pszColorBuff ; LPWSTR optional, out
, "Int", cchMaxColorChars ; INT
, "Ptr", pszSizeBuff ; LPWSTR optional, out
, "Int", cchMaxSizeChars ; INT
, "Int") ; return: HRESULT●GetCurrentThemeName(pszThemeFileName, cchMaxNameChars, pszColorBuff, cchMaxColorChars, pszSizeBuff, cchMaxSizeChars) = DLL("UXTHEME.dll", "int GetCurrentThemeName(char*, int, char*, int, char*, int)")
# 呼び出し: GetCurrentThemeName(pszThemeFileName, cchMaxNameChars, pszColorBuff, cchMaxColorChars, pszSizeBuff, cchMaxSizeChars)
# pszThemeFileName : LPWSTR out -> "char*"
# cchMaxNameChars : INT -> "int"
# pszColorBuff : LPWSTR optional, out -> "char*"
# cchMaxColorChars : INT -> "int"
# pszSizeBuff : LPWSTR optional, out -> "char*"
# cchMaxSizeChars : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。