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

GetPointerType

関数
指定ポインタの種類(タッチ・ペンなど)を取得する。
DLLUSER32.dll呼出規約winapiSetLastErrorあり対応OSwindows8.0

シグネチャ

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

BOOL GetPointerType(
    DWORD pointerId,
    POINTER_INPUT_TYPE* pointerType
);

パラメーター

名前方向説明
pointerIdDWORDin情報を取得する対象ポインタのIDを指定する。
pointerTypePOINTER_INPUT_TYPE*out取得したポインタ種別(タッチ/ペン/マウス等)を受け取るPOINTER_INPUT_TYPEへのポインタ。

戻り値の型: BOOL

各言語での呼び出し定義

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

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

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

lib = Fiddle.dlopen('USER32.dll')
GetPointerType = Fiddle::Function.new(
  lib['GetPointerType'],
  [
    -Fiddle::TYPE_INT,  # pointerId : DWORD
    Fiddle::TYPE_VOIDP,  # pointerType : POINTER_INPUT_TYPE* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn GetPointerType(
        pointerId: u32,  // DWORD
        pointerType: *mut i32  // POINTER_INPUT_TYPE* 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 GetPointerType(uint pointerId, out int pointerType);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetPointerType' -Namespace Win32 -PassThru
# $api::GetPointerType(pointerId, pointerType)
#uselib "USER32.dll"
#func global GetPointerType "GetPointerType" sptr, sptr
; GetPointerType pointerId, pointerType   ; 戻り値は stat
; pointerId : DWORD -> "sptr"
; pointerType : POINTER_INPUT_TYPE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USER32.dll"
#cfunc global GetPointerType "GetPointerType" int, int
; res = GetPointerType(pointerId, pointerType)
; pointerId : DWORD -> "int"
; pointerType : POINTER_INPUT_TYPE* out -> "int"
; BOOL GetPointerType(DWORD pointerId, POINTER_INPUT_TYPE* pointerType)
#uselib "USER32.dll"
#cfunc global GetPointerType "GetPointerType" int, int
; res = GetPointerType(pointerId, pointerType)
; pointerId : DWORD -> "int"
; pointerType : POINTER_INPUT_TYPE* out -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procGetPointerType = user32.NewProc("GetPointerType")
)

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