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