WinBioRegisterEventMonitor
関数シグネチャ
// winbio.dll
#include <windows.h>
HRESULT WinBioRegisterEventMonitor(
DWORD SessionHandle,
DWORD EventMask,
PWINBIO_EVENT_CALLBACK EventCallback,
void* EventCallbackContext // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| SessionHandle | DWORD | in | 開いているバイオメトリックセッションを識別する WINBIO_SESSION_HANDLE 値。セッションハンドルは WinBioOpenSession を呼び出して開きます。 |
| EventMask | DWORD | in | 監視するイベントの種類を指定する値。現在サポートされているのは指紋プロバイダーのみです。次のいずれかのフラグを指定する必要があります。
アプリケーションが要求していない指のスワイプをセンサーが検出したか、要求元のアプリケーションがウィンドウフォーカスを持っていません。Windows Biometric Framework は、指のスワイプが発生したことを示すためにコールバック関数を呼び出しますが、指紋の識別は試みません。
アプリケーションが要求していない指のスワイプをセンサーが検出したか、要求元のアプリケーションがウィンドウフォーカスを持っていません。Windows Biometric Framework は指紋の識別を試み、その処理結果をコールバック関数に渡します。 |
| EventCallback | PWINBIO_EVENT_CALLBACK | in | Windows Biometric Framework から送信されるイベント通知を受け取るコールバック関数のアドレス。この関数はアプリケーション側で定義する必要があります。 |
| EventCallbackContext | void* | inoptional | コールバック関数の pvContext パラメーターで返される、省略可能なアプリケーション定義の値。この値には、カスタムコールバック関数が処理できるように設計された任意のデータを格納できます。 |
戻り値の型: HRESULT
公式ドキュメント
開いているセッションに関連付けられたサービスプロバイダーからイベント通知を受け取るコールバック関数を登録します。
戻り値
関数が成功した場合は S_OK を返します。失敗した場合は、エラーを示す HRESULT 値を返します。返される可能性のある値には、次の表に示すものが含まれます (ただしこれらに限定されません)。一般的なエラーコードの一覧については、Common HRESULT Values を参照してください。
| 戻り値 | 説明 |
|---|---|
| セッションハンドルが無効です。 | |
| EventCallback パラメーターで指定するコールバック関数のアドレスを NULL にすることはできません。 | |
| EventMask パラメーターをゼロにすることはできません。また、WINBIO_EVENT_FP_UNCLAIMED と WINBIO_EVENT_FP_UNCLAIMED_IDENTIFY を同時に指定することもできません。 | |
| アクティブなイベントモニターが既に登録されています。 | |
| サービスプロバイダーがイベント通知をサポートしていません。 |
解説(Remarks)
この関数は、System センサープールに接続されたセッションでのみ有効です。
イベントコールバックは、クライアントアプリケーションに対して順番に (直列に) 配信されます。そのため、クライアントが現在のコールバックから戻るまで、後続のイベント通知は配信されません。コールバックの実行中に発生したイベントは、システムによって破棄されることがあります。イベントを取りこぼさないように、コールバックルーチン内で時間のかかる処理を行わないでください。
クライアントアプリケーションは、WinBioRegisterEventMonitor を呼び出した直後からイベントを受け取れるように準備しておく必要があります。アプリケーションは、コールバックの Event 引数で返される構造体を解放するために WinBioFree を呼び出す必要があります。これを怠ると、呼び出し元プロセスでメモリリークが発生します。
イベントモニターを開始した後は、そのモニターに関連付けられているセッションでは、イベントモニターを停止するまで他の Windows Biometric Framework API 呼び出しを処理できません。イベントモニターの通知を受け取りながら他の API 呼び出しを行う必要がある場合は、セッションを 2 つ開き、一方をイベントモニター用に、もう一方をそれ以外の操作用に使用してください。
コールバック関数へのイベント通知の送信を停止するには、WinBioUnregisterEventMonitor を呼び出します。
アプリケーションが WinBio のイベントモニターを登録し、スリープ/復帰のサイクルを通じてそのモニターをアクティブなままにしていると、バイオメトリックのプリブート認証 (PBA) / シングルサインオン機能を実装しているシステムが正しく動作しない場合があります。これは、システムのバイオメトリック資格情報プロバイダーが最初の WinBioIdentify 操作を実行する前に、PBA のバイオメトリック呼び出しがイベントモニターによって横取りされてしまうためです。WinBio のイベント監視機能を使用するアプリは、システムがスリープする前にモニターの登録を解除し、システムの復帰後に再登録してください。電源状態の変化時のイベント処理について詳しくは、About Power Management を参照してください。
コールバックルーチンは、次のシグネチャを持つ必要があります。
VOID CALLBACK EventCallback(
__in_opt PVOID EventCallbackContext,
__in HRESULT OperationStatus,
__in PWINBIO_EVENT Event
);
例
次の関数は、WinBioRegisterEventMonitor 関数を呼び出してコールバックルーチンのアドレスを渡すことで、イベントモニターを登録します。併せて示しているコールバックは、Windows Biometric Framework からイベント通知を受け取ります。Winbio.lib 静的ライブラリをリンクし、次のヘッダーファイルをインクルードしてください。
- Windows.h
- Stdio.h
- Conio.h
- Winbio.h
HRESULT RegisterSystemEventMonitor(BOOL bCancel)
{
HRESULT hr = S_OK;
WINBIO_SESSION_HANDLE sessionHandle = NULL;
WINBIO_UNIT_ID unitId = 0;
// Connect to the system pool.
hr = WinBioOpenSession(
WINBIO_TYPE_FINGERPRINT, // Service provider
WINBIO_POOL_SYSTEM, // Pool type
WINBIO_FLAG_DEFAULT, // Configuration and access
NULL, // Array of biometric unit IDs
0, // Count of biometric unit IDs
NULL, // Database ID
&sessionHandle // [out] Session handle
);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioOpenSession failed. hr = 0x%x\n", hr);
goto e_Exit;
}
// Call the WinBioRegisterEventMonitor function.
wprintf_s(L"\n Calling WinBioRegisterEventMonitor.\n");
hr = WinBioRegisterEventMonitor(
sessionHandle, // Open session handle
WINBIO_EVENT_FP_UNCLAIMED, // Events to monitor
EventMonitorCallback, // Callback function
NULL // Optional context.
);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioRegisterEventMonitor failed.");
wprintf_s(L"hr = 0x%x\n", hr);
goto e_Exit;
}
wprintf_s(L"\n Waiting for an event.\n");
// Cancel the identification if the bCancel flag is set.
if (bCancel)
{
wprintf_s(L"\n Starting CANCEL timer...\n");
Sleep( 7000 );
wprintf_s(L"\n Calling WinBioCancel\n");
hr = WinBioCancel( sessionHandle );
if (FAILED(hr))
{
wprintf_s(L"\n WinBioCancel failed. hr = 0x%x\n", hr);
goto e_Exit;
}
}
// Wait for an event to happen.
//wprintf_s(L"\n Swipe the sensor to receive an event notice ");
//wprintf_s(L"\n or press any key to stop waiting...\n");
wprintf_s(L"\n Swipe the sensor one or more times ");
wprintf_s(L"to generate events.");
wprintf_s(L"\n When done, press a key to exit...\n");
_getch();
// Unregister the event monitor.
wprintf_s(L"\n Calling WinBioUnregisterEventMonitor\n");
hr = WinBioUnregisterEventMonitor( sessionHandle);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioUnregisterEventMonitor failed.");
wprintf_s(L"hr = 0x%x\n", hr);
}
e_Exit:
if (sessionHandle != NULL)
{
wprintf_s(L"\n Closing the session.\n");
hr = WinBioCloseSession(sessionHandle);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioCloseSession failed. hr = 0x%x\n", hr);
}
sessionHandle = NULL;
}
wprintf_s(L"\n Press any key to exit...");
_getch();
return hr;
}
//------------------------------------------------------------------------
// The following function is the callback for WinBioRegisterEventMonitor.
// The function filters any event notice from the biometric subsystem and
// writes a result to the console window.
//
VOID CALLBACK EventMonitorCallback(
__in_opt PVOID EventCallbackContext,
__in HRESULT OperationStatus,
__in PWINBIO_EVENT Event
)
{
UNREFERENCED_PARAMETER(EventCallbackContext);
wprintf_s(L"\n EventMonitorCallback executing.");
// Failure.
if (FAILED(OperationStatus))
{
wprintf_s(L"\n EventMonitorCallback failed. ");
wprintf_s(L" OperationStatus = 0x%x\n", OperationStatus);
goto e_Exit;
}
// An event notice was received.
if (Event != NULL)
{
wprintf_s(L"\n MonitorEvent: ");
switch (Event->Type)
{
case WINBIO_EVENT_FP_UNCLAIMED:
wprintf_s(L"WINBIO_EVENT_FP_UNCLAIMED");
wprintf_s(L"\n Unit ID: %d",
Event->Parameters.Unclaimed.UnitId);
wprintf_s(L"\n Reject detail: %d\n",
Event->Parameters.Unclaimed.RejectDetail);
break;
case WINBIO_EVENT_FP_UNCLAIMED_IDENTIFY:
wprintf_s(L"WINBIO_EVENT_FP_UNCLAIMED_IDENTIFY");
wprintf_s(L"\n Unit ID: %d",
Event->Parameters.UnclaimedIdentify.UnitId);
wprintf_s(L"\n Reject detail: %d\n",
Event->Parameters.UnclaimedIdentify.RejectDetail);
break;
case WINBIO_EVENT_ERROR:
wprintf_s(L"WINBIO_EVENT_ERROR\n");
break;
default:
wprintf_s(L"(0x%08x - Invalid type)\n", Event->Type);
break;
}
}
e_Exit:
if (Event != NULL)
{
//wprintf_s(L"\n Press any key to continue...\n");
WinBioFree(Event);
Event = NULL;
}
}
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 // HRESULTfunction 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 を使用してください。関連項目
- f WinBioOpenSession — 生体認証操作用のセッションを開きハンドルを取得する。
- f WinBioUnregisterEventMonitor — 登録した生体認証イベントモニターを解除する。