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