Win32 API 日本語リファレンス
ホームUI.Input.Pointer › GetPointerPenInfo

GetPointerPenInfo

関数
指定したポインタのペン入力情報を取得する。
DLLUSER32.dll呼出規約winapiSetLastErrorあり対応OSwindows8.0

シグネチャ

// USER32.dll
#include <windows.h>

BOOL GetPointerPenInfo(
    DWORD pointerId,
    POINTER_PEN_INFO* penInfo
);

パラメーター

名前方向説明
pointerIdDWORDin情報を取得するペンポインタのIDを指定する。
penInfoPOINTER_PEN_INFO*outペン固有情報(筆圧・傾き等)を受け取るPOINTER_PEN_INFO構造体へのポインタ。

戻り値の型: BOOL

各言語での呼び出し定義

// USER32.dll
#include <windows.h>

BOOL GetPointerPenInfo(
    DWORD pointerId,
    POINTER_PEN_INFO* penInfo
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetPointerPenInfo(
    uint pointerId,   // DWORD
    IntPtr penInfo   // POINTER_PEN_INFO* out
);
<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetPointerPenInfo(
    pointerId As UInteger,   ' DWORD
    penInfo As IntPtr   ' POINTER_PEN_INFO* out
) As Boolean
End Function
' pointerId : DWORD
' penInfo : POINTER_PEN_INFO* out
Declare PtrSafe Function GetPointerPenInfo Lib "user32" ( _
    ByVal pointerId As Long, _
    ByVal penInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetPointerPenInfo = ctypes.windll.user32.GetPointerPenInfo
GetPointerPenInfo.restype = wintypes.BOOL
GetPointerPenInfo.argtypes = [
    wintypes.DWORD,  # pointerId : DWORD
    ctypes.c_void_p,  # penInfo : POINTER_PEN_INFO* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
GetPointerPenInfo = Fiddle::Function.new(
  lib['GetPointerPenInfo'],
  [
    -Fiddle::TYPE_INT,  # pointerId : DWORD
    Fiddle::TYPE_VOIDP,  # penInfo : POINTER_PEN_INFO* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn GetPointerPenInfo(
        pointerId: u32,  // DWORD
        penInfo: *mut POINTER_PEN_INFO  // POINTER_PEN_INFO* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true)]
public static extern bool GetPointerPenInfo(uint pointerId, IntPtr penInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetPointerPenInfo' -Namespace Win32 -PassThru
# $api::GetPointerPenInfo(pointerId, penInfo)
#uselib "USER32.dll"
#func global GetPointerPenInfo "GetPointerPenInfo" sptr, sptr
; GetPointerPenInfo pointerId, varptr(penInfo)   ; 戻り値は stat
; pointerId : DWORD -> "sptr"
; penInfo : POINTER_PEN_INFO* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global GetPointerPenInfo "GetPointerPenInfo" int, var
; res = GetPointerPenInfo(pointerId, penInfo)
; pointerId : DWORD -> "int"
; penInfo : POINTER_PEN_INFO* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL GetPointerPenInfo(DWORD pointerId, POINTER_PEN_INFO* penInfo)
#uselib "USER32.dll"
#cfunc global GetPointerPenInfo "GetPointerPenInfo" int, var
; res = GetPointerPenInfo(pointerId, penInfo)
; pointerId : DWORD -> "int"
; penInfo : POINTER_PEN_INFO* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procGetPointerPenInfo = user32.NewProc("GetPointerPenInfo")
)

// pointerId (DWORD), penInfo (POINTER_PEN_INFO* out)
r1, _, err := procGetPointerPenInfo.Call(
	uintptr(pointerId),
	uintptr(penInfo),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GetPointerPenInfo(
  pointerId: DWORD;   // DWORD
  penInfo: Pointer   // POINTER_PEN_INFO* out
): BOOL; stdcall;
  external 'USER32.dll' name 'GetPointerPenInfo';
result := DllCall("USER32\GetPointerPenInfo"
    , "UInt", pointerId   ; DWORD
    , "Ptr", penInfo   ; POINTER_PEN_INFO* out
    , "Int")   ; return: BOOL
●GetPointerPenInfo(pointerId, penInfo) = DLL("USER32.dll", "bool GetPointerPenInfo(dword, void*)")
# 呼び出し: GetPointerPenInfo(pointerId, penInfo)
# pointerId : DWORD -> "dword"
# penInfo : POINTER_PEN_INFO* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。