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