Win32 API 日本語リファレンス
ホームDevices.BiometricFramework › WinBioRegisterEventMonitor

WinBioRegisterEventMonitor

関数
生体認証イベントの通知用コールバックを登録する。
DLLwinbio.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

HRESULT WinBioRegisterEventMonitor(
    DWORD SessionHandle,
    DWORD EventMask,
    PWINBIO_EVENT_CALLBACK EventCallback,
    void* EventCallbackContext   // optional
);

パラメーター

名前方向説明
SessionHandleDWORDinイベント監視を登録するセッションのハンドル。
EventMaskDWORDin監視するイベント種別を示すフラグ。センサータッチ等のWINBIO_EVENT値。
EventCallbackPWINBIO_EVENT_CALLBACKinイベント発生時に呼ばれるコールバック関数へのポインタ。
EventCallbackContextvoid*inoptionalコールバックに渡される任意のコンテキストポインタ。NULL可。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WinBioRegisterEventMonitor(
    DWORD SessionHandle,
    DWORD EventMask,
    PWINBIO_EVENT_CALLBACK EventCallback,
    void* EventCallbackContext   // optional
);
[DllImport("winbio.dll", ExactSpelling = true)]
static extern int WinBioRegisterEventMonitor(
    uint SessionHandle,   // DWORD
    uint EventMask,   // DWORD
    IntPtr EventCallback,   // PWINBIO_EVENT_CALLBACK
    IntPtr EventCallbackContext   // void* optional
);
<DllImport("winbio.dll", ExactSpelling:=True)>
Public Shared Function WinBioRegisterEventMonitor(
    SessionHandle As UInteger,   ' DWORD
    EventMask As UInteger,   ' DWORD
    EventCallback As IntPtr,   ' PWINBIO_EVENT_CALLBACK
    EventCallbackContext As IntPtr   ' void* optional
) As Integer
End Function
' SessionHandle : DWORD
' EventMask : DWORD
' EventCallback : PWINBIO_EVENT_CALLBACK
' EventCallbackContext : void* optional
Declare PtrSafe Function WinBioRegisterEventMonitor Lib "winbio" ( _
    ByVal SessionHandle As Long, _
    ByVal EventMask As Long, _
    ByVal EventCallback As LongPtr, _
    ByVal EventCallbackContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WinBioRegisterEventMonitor = ctypes.windll.winbio.WinBioRegisterEventMonitor
WinBioRegisterEventMonitor.restype = ctypes.c_int
WinBioRegisterEventMonitor.argtypes = [
    wintypes.DWORD,  # SessionHandle : DWORD
    wintypes.DWORD,  # EventMask : DWORD
    ctypes.c_void_p,  # EventCallback : PWINBIO_EVENT_CALLBACK
    ctypes.POINTER(None),  # EventCallbackContext : void* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('winbio.dll')
WinBioRegisterEventMonitor = Fiddle::Function.new(
  lib['WinBioRegisterEventMonitor'],
  [
    -Fiddle::TYPE_INT,  # SessionHandle : DWORD
    -Fiddle::TYPE_INT,  # EventMask : DWORD
    Fiddle::TYPE_VOIDP,  # EventCallback : PWINBIO_EVENT_CALLBACK
    Fiddle::TYPE_VOIDP,  # EventCallbackContext : void* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "winbio")]
extern "system" {
    fn WinBioRegisterEventMonitor(
        SessionHandle: u32,  // DWORD
        EventMask: u32,  // DWORD
        EventCallback: *const core::ffi::c_void,  // PWINBIO_EVENT_CALLBACK
        EventCallbackContext: *mut ()  // void* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("winbio.dll")]
public static extern int WinBioRegisterEventMonitor(uint SessionHandle, uint EventMask, IntPtr EventCallback, IntPtr EventCallbackContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winbio_WinBioRegisterEventMonitor' -Namespace Win32 -PassThru
# $api::WinBioRegisterEventMonitor(SessionHandle, EventMask, EventCallback, EventCallbackContext)
#uselib "winbio.dll"
#func global WinBioRegisterEventMonitor "WinBioRegisterEventMonitor" sptr, sptr, sptr, sptr
; WinBioRegisterEventMonitor SessionHandle, EventMask, EventCallback, EventCallbackContext   ; 戻り値は stat
; SessionHandle : DWORD -> "sptr"
; EventMask : DWORD -> "sptr"
; EventCallback : PWINBIO_EVENT_CALLBACK -> "sptr"
; EventCallbackContext : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "winbio.dll"
#cfunc global WinBioRegisterEventMonitor "WinBioRegisterEventMonitor" int, int, sptr, sptr
; res = WinBioRegisterEventMonitor(SessionHandle, EventMask, EventCallback, EventCallbackContext)
; SessionHandle : DWORD -> "int"
; EventMask : DWORD -> "int"
; EventCallback : PWINBIO_EVENT_CALLBACK -> "sptr"
; EventCallbackContext : void* optional -> "sptr"
; HRESULT WinBioRegisterEventMonitor(DWORD SessionHandle, DWORD EventMask, PWINBIO_EVENT_CALLBACK EventCallback, void* EventCallbackContext)
#uselib "winbio.dll"
#cfunc global WinBioRegisterEventMonitor "WinBioRegisterEventMonitor" int, int, intptr, intptr
; res = WinBioRegisterEventMonitor(SessionHandle, EventMask, EventCallback, EventCallbackContext)
; SessionHandle : DWORD -> "int"
; EventMask : DWORD -> "int"
; EventCallback : PWINBIO_EVENT_CALLBACK -> "intptr"
; EventCallbackContext : void* optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winbio = windows.NewLazySystemDLL("winbio.dll")
	procWinBioRegisterEventMonitor = winbio.NewProc("WinBioRegisterEventMonitor")
)

// SessionHandle (DWORD), EventMask (DWORD), EventCallback (PWINBIO_EVENT_CALLBACK), EventCallbackContext (void* optional)
r1, _, err := procWinBioRegisterEventMonitor.Call(
	uintptr(SessionHandle),
	uintptr(EventMask),
	uintptr(EventCallback),
	uintptr(EventCallbackContext),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WinBioRegisterEventMonitor(
  SessionHandle: DWORD;   // DWORD
  EventMask: DWORD;   // DWORD
  EventCallback: Pointer;   // PWINBIO_EVENT_CALLBACK
  EventCallbackContext: Pointer   // void* optional
): Integer; stdcall;
  external 'winbio.dll' name 'WinBioRegisterEventMonitor';
result := DllCall("winbio\WinBioRegisterEventMonitor"
    , "UInt", SessionHandle   ; DWORD
    , "UInt", EventMask   ; DWORD
    , "Ptr", EventCallback   ; PWINBIO_EVENT_CALLBACK
    , "Ptr", EventCallbackContext   ; void* optional
    , "Int")   ; return: HRESULT
●WinBioRegisterEventMonitor(SessionHandle, EventMask, EventCallback, EventCallbackContext) = DLL("winbio.dll", "int WinBioRegisterEventMonitor(dword, dword, void*, void*)")
# 呼び出し: WinBioRegisterEventMonitor(SessionHandle, EventMask, EventCallback, EventCallbackContext)
# SessionHandle : DWORD -> "dword"
# EventMask : DWORD -> "dword"
# EventCallback : PWINBIO_EVENT_CALLBACK -> "void*"
# EventCallbackContext : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "winbio" fn WinBioRegisterEventMonitor(
    SessionHandle: u32, // DWORD
    EventMask: u32, // DWORD
    EventCallback: ?*anyopaque, // PWINBIO_EVENT_CALLBACK
    EventCallbackContext: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) i32;
proc WinBioRegisterEventMonitor(
    SessionHandle: uint32,  # DWORD
    EventMask: uint32,  # DWORD
    EventCallback: pointer,  # PWINBIO_EVENT_CALLBACK
    EventCallbackContext: pointer  # void* optional
): int32 {.importc: "WinBioRegisterEventMonitor", stdcall, dynlib: "winbio.dll".}
pragma(lib, "winbio");
extern(Windows)
int WinBioRegisterEventMonitor(
    uint SessionHandle,   // DWORD
    uint EventMask,   // DWORD
    void* EventCallback,   // PWINBIO_EVENT_CALLBACK
    void* EventCallbackContext   // void* optional
);
ccall((:WinBioRegisterEventMonitor, "winbio.dll"), stdcall, Int32,
      (UInt32, UInt32, Ptr{Cvoid}, Ptr{Cvoid}),
      SessionHandle, EventMask, EventCallback, EventCallbackContext)
# SessionHandle : DWORD -> UInt32
# EventMask : DWORD -> UInt32
# EventCallback : PWINBIO_EVENT_CALLBACK -> Ptr{Cvoid}
# EventCallbackContext : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WinBioRegisterEventMonitor(
    uint32_t SessionHandle,
    uint32_t EventMask,
    void* EventCallback,
    void* EventCallbackContext);
]]
local winbio = ffi.load("winbio")
-- winbio.WinBioRegisterEventMonitor(SessionHandle, EventMask, EventCallback, EventCallbackContext)
-- SessionHandle : DWORD
-- EventMask : DWORD
-- EventCallback : PWINBIO_EVENT_CALLBACK
-- EventCallbackContext : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('winbio.dll');
const WinBioRegisterEventMonitor = lib.func('__stdcall', 'WinBioRegisterEventMonitor', 'int32_t', ['uint32_t', 'uint32_t', 'void *', 'void *']);
// WinBioRegisterEventMonitor(SessionHandle, EventMask, EventCallback, EventCallbackContext)
// SessionHandle : DWORD -> 'uint32_t'
// EventMask : DWORD -> 'uint32_t'
// EventCallback : PWINBIO_EVENT_CALLBACK -> 'void *'
// EventCallbackContext : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。
const lib = Deno.dlopen("winbio.dll", {
  WinBioRegisterEventMonitor: { parameters: ["u32", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WinBioRegisterEventMonitor(SessionHandle, EventMask, EventCallback, EventCallbackContext)
// SessionHandle : DWORD -> "u32"
// EventMask : DWORD -> "u32"
// EventCallback : PWINBIO_EVENT_CALLBACK -> "pointer"
// EventCallbackContext : void* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WinBioRegisterEventMonitor(
    uint32_t SessionHandle,
    uint32_t EventMask,
    void* EventCallback,
    void* EventCallbackContext);
C, "winbio.dll");
// $ffi->WinBioRegisterEventMonitor(SessionHandle, EventMask, EventCallback, EventCallbackContext);
// SessionHandle : DWORD
// EventMask : DWORD
// EventCallback : PWINBIO_EVENT_CALLBACK
// EventCallbackContext : void* optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Winbio extends StdCallLibrary {
    Winbio INSTANCE = Native.load("winbio", Winbio.class);
    int WinBioRegisterEventMonitor(
        int SessionHandle,   // DWORD
        int EventMask,   // DWORD
        Callback EventCallback,   // PWINBIO_EVENT_CALLBACK
        Pointer EventCallbackContext   // void* optional
    );
}
@[Link("winbio")]
lib Libwinbio
  fun WinBioRegisterEventMonitor = WinBioRegisterEventMonitor(
    SessionHandle : UInt32,   # DWORD
    EventMask : UInt32,   # DWORD
    EventCallback : Void*,   # PWINBIO_EVENT_CALLBACK
    EventCallbackContext : Void*   # void* optional
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WinBioRegisterEventMonitorNative = Int32 Function(Uint32, Uint32, Pointer<Void>, Pointer<Void>);
typedef WinBioRegisterEventMonitorDart = int Function(int, int, Pointer<Void>, Pointer<Void>);
final WinBioRegisterEventMonitor = DynamicLibrary.open('winbio.dll')
    .lookupFunction<WinBioRegisterEventMonitorNative, WinBioRegisterEventMonitorDart>('WinBioRegisterEventMonitor');
// SessionHandle : DWORD -> Uint32
// EventMask : DWORD -> Uint32
// EventCallback : PWINBIO_EVENT_CALLBACK -> Pointer<Void>
// EventCallbackContext : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WinBioRegisterEventMonitor(
  SessionHandle: DWORD;   // DWORD
  EventMask: DWORD;   // DWORD
  EventCallback: Pointer;   // PWINBIO_EVENT_CALLBACK
  EventCallbackContext: Pointer   // void* optional
): Integer; stdcall;
  external 'winbio.dll' name 'WinBioRegisterEventMonitor';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WinBioRegisterEventMonitor"
  c_WinBioRegisterEventMonitor :: Word32 -> Word32 -> Ptr () -> Ptr () -> IO Int32
-- SessionHandle : DWORD -> Word32
-- EventMask : DWORD -> Word32
-- EventCallback : PWINBIO_EVENT_CALLBACK -> Ptr ()
-- EventCallbackContext : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let winbioregistereventmonitor =
  foreign "WinBioRegisterEventMonitor"
    (uint32_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* SessionHandle : DWORD -> uint32_t *)
(* EventMask : DWORD -> uint32_t *)
(* EventCallback : PWINBIO_EVENT_CALLBACK -> (ptr void) *)
(* EventCallbackContext : void* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library winbio (t "winbio.dll"))
(cffi:use-foreign-library winbio)

(cffi:defcfun ("WinBioRegisterEventMonitor" win-bio-register-event-monitor :convention :stdcall) :int32
  (session-handle :uint32)   ; DWORD
  (event-mask :uint32)   ; DWORD
  (event-callback :pointer)   ; PWINBIO_EVENT_CALLBACK
  (event-callback-context :pointer))   ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WinBioRegisterEventMonitor = Win32::API::More->new('winbio',
    'int WinBioRegisterEventMonitor(DWORD SessionHandle, DWORD EventMask, LPVOID EventCallback, LPVOID EventCallbackContext)');
# my $ret = $WinBioRegisterEventMonitor->Call($SessionHandle, $EventMask, $EventCallback, $EventCallbackContext);
# SessionHandle : DWORD -> DWORD
# EventMask : DWORD -> DWORD
# EventCallback : PWINBIO_EVENT_CALLBACK -> LPVOID
# EventCallbackContext : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

使用する型