Win32 API 日本語リファレンス
ホームUI.Controls › RegisterPointerDeviceNotifications

RegisterPointerDeviceNotifications

関数
ポインターデバイスの変更通知をウィンドウに登録する。
DLLUSER32.dll呼出規約winapiSetLastErrorあり対応OSwindows8.0

シグネチャ

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

BOOL RegisterPointerDeviceNotifications(
    HWND window,
    BOOL notifyRange
);

パラメーター

名前方向
windowHWNDin
notifyRangeBOOLin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

RegisterPointerDeviceNotifications = ctypes.windll.user32.RegisterPointerDeviceNotifications
RegisterPointerDeviceNotifications.restype = wintypes.BOOL
RegisterPointerDeviceNotifications.argtypes = [
    wintypes.HANDLE,  # window : HWND
    wintypes.BOOL,  # notifyRange : BOOL
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procRegisterPointerDeviceNotifications = user32.NewProc("RegisterPointerDeviceNotifications")
)

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