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