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