ホーム › UI.WindowsAndMessaging › GetClassLongW
GetClassLongW
関数ウィンドウクラスの属性値を取得する(Unicode版)。
シグネチャ
// USER32.dll (Unicode / -W)
#include <windows.h>
DWORD GetClassLongW(
HWND hWnd,
GET_CLASS_LONG_INDEX nIndex
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hWnd | HWND | in |
| nIndex | GET_CLASS_LONG_INDEX | in |
戻り値の型: DWORD
各言語での呼び出し定義
// USER32.dll (Unicode / -W)
#include <windows.h>
DWORD GetClassLongW(
HWND hWnd,
GET_CLASS_LONG_INDEX nIndex
);[DllImport("USER32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern uint GetClassLongW(
IntPtr hWnd, // HWND
int nIndex // GET_CLASS_LONG_INDEX
);<DllImport("USER32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetClassLongW(
hWnd As IntPtr, ' HWND
nIndex As Integer ' GET_CLASS_LONG_INDEX
) As UInteger
End Function' hWnd : HWND
' nIndex : GET_CLASS_LONG_INDEX
Declare PtrSafe Function GetClassLongW Lib "user32" ( _
ByVal hWnd As LongPtr, _
ByVal nIndex As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetClassLongW = ctypes.windll.user32.GetClassLongW
GetClassLongW.restype = wintypes.DWORD
GetClassLongW.argtypes = [
wintypes.HANDLE, # hWnd : HWND
ctypes.c_int, # nIndex : GET_CLASS_LONG_INDEX
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
GetClassLongW = Fiddle::Function.new(
lib['GetClassLongW'],
[
Fiddle::TYPE_VOIDP, # hWnd : HWND
Fiddle::TYPE_INT, # nIndex : GET_CLASS_LONG_INDEX
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "user32")]
extern "system" {
fn GetClassLongW(
hWnd: *mut core::ffi::c_void, // HWND
nIndex: i32 // GET_CLASS_LONG_INDEX
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USER32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern uint GetClassLongW(IntPtr hWnd, int nIndex);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetClassLongW' -Namespace Win32 -PassThru
# $api::GetClassLongW(hWnd, nIndex)#uselib "USER32.dll"
#func global GetClassLongW "GetClassLongW" wptr, wptr
; GetClassLongW hWnd, nIndex ; 戻り値は stat
; hWnd : HWND -> "wptr"
; nIndex : GET_CLASS_LONG_INDEX -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global GetClassLongW "GetClassLongW" sptr, int
; res = GetClassLongW(hWnd, nIndex)
; hWnd : HWND -> "sptr"
; nIndex : GET_CLASS_LONG_INDEX -> "int"; DWORD GetClassLongW(HWND hWnd, GET_CLASS_LONG_INDEX nIndex)
#uselib "USER32.dll"
#cfunc global GetClassLongW "GetClassLongW" intptr, int
; res = GetClassLongW(hWnd, nIndex)
; hWnd : HWND -> "intptr"
; nIndex : GET_CLASS_LONG_INDEX -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procGetClassLongW = user32.NewProc("GetClassLongW")
)
// hWnd (HWND), nIndex (GET_CLASS_LONG_INDEX)
r1, _, err := procGetClassLongW.Call(
uintptr(hWnd),
uintptr(nIndex),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction GetClassLongW(
hWnd: THandle; // HWND
nIndex: Integer // GET_CLASS_LONG_INDEX
): DWORD; stdcall;
external 'USER32.dll' name 'GetClassLongW';result := DllCall("USER32\GetClassLongW"
, "Ptr", hWnd ; HWND
, "Int", nIndex ; GET_CLASS_LONG_INDEX
, "UInt") ; return: DWORD●GetClassLongW(hWnd, nIndex) = DLL("USER32.dll", "dword GetClassLongW(void*, int)")
# 呼び出し: GetClassLongW(hWnd, nIndex)
# hWnd : HWND -> "void*"
# nIndex : GET_CLASS_LONG_INDEX -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。