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