ホーム › UI.WindowsAndMessaging › GetClassInfoExA
GetClassInfoExA
関数拡張ウィンドウクラス情報を取得する(ANSI)。
シグネチャ
// USER32.dll (ANSI / -A)
#include <windows.h>
BOOL GetClassInfoExA(
HINSTANCE hInstance, // optional
LPCSTR lpszClass,
WNDCLASSEXA* lpwcx
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hInstance | HINSTANCE | inoptional |
| lpszClass | LPCSTR | in |
| lpwcx | WNDCLASSEXA* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// USER32.dll (ANSI / -A)
#include <windows.h>
BOOL GetClassInfoExA(
HINSTANCE hInstance, // optional
LPCSTR lpszClass,
WNDCLASSEXA* lpwcx
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool GetClassInfoExA(
IntPtr hInstance, // HINSTANCE optional
[MarshalAs(UnmanagedType.LPStr)] string lpszClass, // LPCSTR
IntPtr lpwcx // WNDCLASSEXA* out
);<DllImport("USER32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetClassInfoExA(
hInstance As IntPtr, ' HINSTANCE optional
<MarshalAs(UnmanagedType.LPStr)> lpszClass As String, ' LPCSTR
lpwcx As IntPtr ' WNDCLASSEXA* out
) As Boolean
End Function' hInstance : HINSTANCE optional
' lpszClass : LPCSTR
' lpwcx : WNDCLASSEXA* out
Declare PtrSafe Function GetClassInfoExA Lib "user32" ( _
ByVal hInstance As LongPtr, _
ByVal lpszClass As String, _
ByVal lpwcx As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetClassInfoExA = ctypes.windll.user32.GetClassInfoExA
GetClassInfoExA.restype = wintypes.BOOL
GetClassInfoExA.argtypes = [
wintypes.HANDLE, # hInstance : HINSTANCE optional
wintypes.LPCSTR, # lpszClass : LPCSTR
ctypes.c_void_p, # lpwcx : WNDCLASSEXA* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
GetClassInfoExA = Fiddle::Function.new(
lib['GetClassInfoExA'],
[
Fiddle::TYPE_VOIDP, # hInstance : HINSTANCE optional
Fiddle::TYPE_VOIDP, # lpszClass : LPCSTR
Fiddle::TYPE_VOIDP, # lpwcx : WNDCLASSEXA* out
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn GetClassInfoExA(
hInstance: *mut core::ffi::c_void, // HINSTANCE optional
lpszClass: *const u8, // LPCSTR
lpwcx: *mut WNDCLASSEXA // WNDCLASSEXA* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool GetClassInfoExA(IntPtr hInstance, [MarshalAs(UnmanagedType.LPStr)] string lpszClass, IntPtr lpwcx);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetClassInfoExA' -Namespace Win32 -PassThru
# $api::GetClassInfoExA(hInstance, lpszClass, lpwcx)#uselib "USER32.dll"
#func global GetClassInfoExA "GetClassInfoExA" sptr, sptr, sptr
; GetClassInfoExA hInstance, lpszClass, varptr(lpwcx) ; 戻り値は stat
; hInstance : HINSTANCE optional -> "sptr"
; lpszClass : LPCSTR -> "sptr"
; lpwcx : WNDCLASSEXA* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global GetClassInfoExA "GetClassInfoExA" sptr, str, var ; res = GetClassInfoExA(hInstance, lpszClass, lpwcx) ; hInstance : HINSTANCE optional -> "sptr" ; lpszClass : LPCSTR -> "str" ; lpwcx : WNDCLASSEXA* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global GetClassInfoExA "GetClassInfoExA" sptr, str, sptr ; res = GetClassInfoExA(hInstance, lpszClass, varptr(lpwcx)) ; hInstance : HINSTANCE optional -> "sptr" ; lpszClass : LPCSTR -> "str" ; lpwcx : WNDCLASSEXA* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetClassInfoExA(HINSTANCE hInstance, LPCSTR lpszClass, WNDCLASSEXA* lpwcx) #uselib "USER32.dll" #cfunc global GetClassInfoExA "GetClassInfoExA" intptr, str, var ; res = GetClassInfoExA(hInstance, lpszClass, lpwcx) ; hInstance : HINSTANCE optional -> "intptr" ; lpszClass : LPCSTR -> "str" ; lpwcx : WNDCLASSEXA* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetClassInfoExA(HINSTANCE hInstance, LPCSTR lpszClass, WNDCLASSEXA* lpwcx) #uselib "USER32.dll" #cfunc global GetClassInfoExA "GetClassInfoExA" intptr, str, intptr ; res = GetClassInfoExA(hInstance, lpszClass, varptr(lpwcx)) ; hInstance : HINSTANCE optional -> "intptr" ; lpszClass : LPCSTR -> "str" ; lpwcx : WNDCLASSEXA* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procGetClassInfoExA = user32.NewProc("GetClassInfoExA")
)
// hInstance (HINSTANCE optional), lpszClass (LPCSTR), lpwcx (WNDCLASSEXA* out)
r1, _, err := procGetClassInfoExA.Call(
uintptr(hInstance),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszClass))),
uintptr(lpwcx),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetClassInfoExA(
hInstance: THandle; // HINSTANCE optional
lpszClass: PAnsiChar; // LPCSTR
lpwcx: Pointer // WNDCLASSEXA* out
): BOOL; stdcall;
external 'USER32.dll' name 'GetClassInfoExA';result := DllCall("USER32\GetClassInfoExA"
, "Ptr", hInstance ; HINSTANCE optional
, "AStr", lpszClass ; LPCSTR
, "Ptr", lpwcx ; WNDCLASSEXA* out
, "Int") ; return: BOOL●GetClassInfoExA(hInstance, lpszClass, lpwcx) = DLL("USER32.dll", "bool GetClassInfoExA(void*, char*, void*)")
# 呼び出し: GetClassInfoExA(hInstance, lpszClass, lpwcx)
# hInstance : HINSTANCE optional -> "void*"
# lpszClass : LPCSTR -> "char*"
# lpwcx : WNDCLASSEXA* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。