WinBioEnrollCaptureWithCallback
関数シグネチャ
// winbio.dll
#include <windows.h>
HRESULT WinBioEnrollCaptureWithCallback(
DWORD SessionHandle,
PWINBIO_ENROLL_CAPTURE_CALLBACK EnrollCallback,
void* EnrollCallbackContext // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| SessionHandle | DWORD | in | 開いている生体認証セッションを識別する WINBIO_SESSION_HANDLE 値です。 |
| EnrollCallback | PWINBIO_ENROLL_CAPTURE_CALLBACK | in | キャプチャ操作が成功または失敗したときに WinBioEnrollCaptureWithCallback 関数によって呼び出されるコールバック関数のアドレスです。このコールバックは自分で作成する必要があります。 |
| EnrollCallbackContext | void* | inoptional | コールバック関数の EnrollCallbackContext パラメーターに渡される、省略可能なアプリケーション定義の構造体へのポインターです。この構造体には、カスタムコールバック関数が処理できるように設計された任意のデータを格納できます。 |
戻り値の型: HRESULT
公式ドキュメント
生体サンプルを非同期にキャプチャし、テンプレートに追加します。
戻り値
関数が成功した場合は S_OK を返します。関数が失敗した場合は、エラーを示す HRESULT 値を返します。返される可能性のある値には、次の表に示すものが含まれますが、これらに限定されません。一般的なエラーコードの一覧については、Common HRESULT Values を参照してください。
| 戻り値 | 説明 |
|---|---|
| 呼び出し元のアカウントには、登録 (エンロール) を実行することが許可されていません。 | |
| セッションハンドルが有効ではありません。 | |
| EnrollCallback パラメーターで指定するポインターを NULL にすることはできません。 |
解説(Remarks)
SessionHandle パラメーターがシステムセンサープールを参照している場合、アプリケーションがウィンドウフォーカスを取得し、ユーザーが生体サンプルを提供するまで、コールバック関数は呼び出されません。フォーカスを取得する方法は、作成するアプリケーションの種類によって異なります。たとえば、GUI アプリケーションを作成する場合は、WM_ACTIVATE、WM_SETFOCUS などの適切なメッセージを捕捉するメッセージハンドラーを実装できます。CUI アプリケーションを作成する場合は、GetConsoleWindow を呼び出してコンソールウィンドウのハンドルを取得し、そのハンドルを SetForegroundWindow 関数に渡して、コンソールウィンドウを強制的に前面に移動させてフォーカスを割り当てます。アプリケーションがデタッチされたプロセスで実行されていてウィンドウを持たない場合や、Windows サービスである場合は、WinBioAcquireFocus と WinBioReleaseFocus を使用してフォーカスを手動で制御します。
例
次のコード例では、WinBioEnrollCaptureWithCallback を呼び出してカスタムコールバック関数へのポインターを渡すことで、指紋を非同期に登録します。コールバック関数である EnrollCaptureCallback も示します。Winbio.lib 静的ライブラリにリンクしてください。
//------------------------------------------------------------------------
// EnrollSystemPoolWithCallback.cpp : console application entry point.
//
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <winbio.h>
//------------------------------------------------------------------------
// Forward declarations.
//
HRESULT EnrollSysPoolWithCallback(
BOOL bCancel,
BOOL bDiscard,
WINBIO_BIOMETRIC_SUBTYPE subFactor);
VOID CALLBACK EnrollCaptureCallback(
__in_opt PVOID EnrollCallbackContext,
__in HRESULT OperationStatus,
__in WINBIO_REJECT_DETAIL RejectDetail);
typedef struct _ENROLL_CALLBACK_CONTEXT {
WINBIO_SESSION_HANDLE SessionHandle;
WINBIO_UNIT_ID UnitId;
WINBIO_BIOMETRIC_SUBTYPE SubFactor;
} ENROLL_CALLBACK_CONTEXT, *PENROLL_CALLBACK_CONTEXT;
//------------------------------------------------------------------------
int wmain()
{
HRESULT hr = S_OK;
hr = EnrollSysPoolWithCallback(
FALSE,
FALSE,
WINBIO_ANSI_381_POS_RH_INDEX_FINGER);
return 0;
}
//------------------------------------------------------------------------
// The following function enrolls a user's fingerprint in the system pool.
// The function calls WinBioEnrollCaptureWithCallback and waits for the
// asynchronous enrollment process to be completed or canceled.
//
HRESULT EnrollSysPoolWithCallback(
BOOL bCancel,
BOOL bDiscard,
WINBIO_BIOMETRIC_SUBTYPE subFactor)
{
// Declare variables
HRESULT hr = S_OK;
WINBIO_IDENTITY identity = {0};
WINBIO_SESSION_HANDLE sessionHandle = NULL;
WINBIO_UNIT_ID unitId = 0;
BOOLEAN isNewTemplate = TRUE;
ENROLL_CALLBACK_CONTEXT callbackContext = {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 WinBioEnumBiometricUnits failed. ");
wprintf_s(L"hr = 0x%x\n", hr);
goto e_Exit;
}
// Locate the sensor.
wprintf_s(L"\n Swipe your finger to locate the sensor...\n");
hr = WinBioLocateSensor( sessionHandle, &unitId);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioLocateSensor failed. hr = 0x%x\n", hr);
goto e_Exit;
}
// Begin the enrollment sequence.
hr = WinBioEnrollBegin(
sessionHandle, // Handle to open biometric session
subFactor, // Finger to create template for
unitId // Biometric unit ID
);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioEnrollBegin failed. hr = 0x%x\n", hr);
goto e_Exit;
}
// Set up the custom callback context structure.
callbackContext.SessionHandle = sessionHandle;
callbackContext.UnitId = unitId;
callbackContext.SubFactor = subFactor;
// Call WinBioEnrollCaptureWithCallback. This is an asynchronous
// method that returns immediately.
hr = WinBioEnrollCaptureWithCallback(
sessionHandle, // Handle to open biometric session
EnrollCaptureCallback, // Callback function
&callbackContext // Pointer to the custom context
);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioEnrollCaptureWithCallback failed. ");
wprintf_s(L"hr = 0x%x\n", hr);
goto e_Exit;
}
wprintf_s(L"\n Swipe the sensor with the appropriate finger...\n");
// Cancel the enrollment 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 the asynchronous enrollment process to complete
// or be canceled.
hr = WinBioWait( sessionHandle );
if (FAILED(hr))
{
wprintf_s(L"\n WinBioWait failed. hr = 0x%x\n", hr);
}
// Discard the enrollment if the bDiscard flag is set.
// Commit the enrollment if the flag is not set.
if (bDiscard)
{
wprintf_s(L"\n Discarding enrollment...\n");
hr = WinBioEnrollDiscard( sessionHandle );
if (FAILED(hr))
{
wprintf_s(L"\n WinBioLocateSensor failed. ");
wprintf_s(L"hr = 0x%x\n", hr);
}
goto e_Exit;
}
else
{
wprintf_s(L"\n Committing enrollment...\n");
hr = WinBioEnrollCommit(
sessionHandle, // Handle to open biometric session
&identity, // WINBIO_IDENTITY object for the user
&isNewTemplate); // Is this a new template
if (FAILED(hr))
{
wprintf_s(L"\n WinBioEnrollCommit failed. hr = 0x%x\n", hr);
goto e_Exit;
}
}
e_Exit:
if (sessionHandle != NULL)
{
WinBioCloseSession(sessionHandle);
sessionHandle = NULL;
}
wprintf_s(L"\n Press any key to exit...");
_getch();
return hr;
}
//------------------------------------------------------------------------
// The following function is the callback for the Windows Biometric
// Framework WinBioEnrollCaptureWithCallback() function.
//
VOID CALLBACK EnrollCaptureCallback(
__in_opt PVOID EnrollCallbackContext,
__in HRESULT OperationStatus,
__in WINBIO_REJECT_DETAIL RejectDetail
)
{
// Declare variables.
HRESULT hr = S_OK;
static SIZE_T swipeCount = 1;
PENROLL_CALLBACK_CONTEXT callbackContext =
(PENROLL_CALLBACK_CONTEXT)EnrollCallbackContext;
wprintf_s(L"\n EnrollCaptureCallback executing\n");
wprintf_s(L"\n Sample %d captured", swipeCount++);
// The capture was not acceptable or the enrollment operation
// failed.
if (FAILED(OperationStatus))
{
if (OperationStatus == WINBIO_E_BAD_CAPTURE)
{
wprintf_s(L"\n Bad capture; reason: %d\n", RejectDetail);
wprintf_s(L"\n Swipe your finger to capture another sample.\n");
// Try again.
hr = WinBioEnrollCaptureWithCallback(
callbackContext->SessionHandle, // Open session handle
EnrollCaptureCallback, // Callback function
EnrollCallbackContext // Callback context
);
if (FAILED(hr))
{
wprintf_s(L"WinBioEnrollCaptureWithCallback failed.");
wprintf_s(L"hr = 0x%x\n", hr);
}
}
else
{
wprintf_s(L"EnrollCaptureCallback failed.");
wprintf_s(L"OperationStatus = 0x%x\n", OperationStatus);
}
goto e_Exit;
}
// The enrollment operation requires more fingerprint swipes.
// This is normal and depends on your hardware. Typically, at least
// three swipes are required.
if (OperationStatus == WINBIO_I_MORE_DATA)
{
wprintf_s(L"\n More data required.");
wprintf_s(L"\n Swipe your finger on the sensor again.");
hr = WinBioEnrollCaptureWithCallback(
callbackContext->SessionHandle,
EnrollCaptureCallback,
EnrollCallbackContext
);
if (FAILED(hr))
{
wprintf_s(L"WinBioEnrollCaptureWithCallback failed. ");
wprintf_s(L"hr = 0x%x\n", hr);
}
goto e_Exit;
}
wprintf_s(L"\n Template completed\n");
e_Exit:
return;
}
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// winbio.dll
#include <windows.h>
HRESULT WinBioEnrollCaptureWithCallback(
DWORD SessionHandle,
PWINBIO_ENROLL_CAPTURE_CALLBACK EnrollCallback,
void* EnrollCallbackContext // optional
);[DllImport("winbio.dll", ExactSpelling = true)]
static extern int WinBioEnrollCaptureWithCallback(
uint SessionHandle, // DWORD
IntPtr EnrollCallback, // PWINBIO_ENROLL_CAPTURE_CALLBACK
IntPtr EnrollCallbackContext // void* optional
);<DllImport("winbio.dll", ExactSpelling:=True)>
Public Shared Function WinBioEnrollCaptureWithCallback(
SessionHandle As UInteger, ' DWORD
EnrollCallback As IntPtr, ' PWINBIO_ENROLL_CAPTURE_CALLBACK
EnrollCallbackContext As IntPtr ' void* optional
) As Integer
End Function' SessionHandle : DWORD
' EnrollCallback : PWINBIO_ENROLL_CAPTURE_CALLBACK
' EnrollCallbackContext : void* optional
Declare PtrSafe Function WinBioEnrollCaptureWithCallback Lib "winbio" ( _
ByVal SessionHandle As Long, _
ByVal EnrollCallback As LongPtr, _
ByVal EnrollCallbackContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WinBioEnrollCaptureWithCallback = ctypes.windll.winbio.WinBioEnrollCaptureWithCallback
WinBioEnrollCaptureWithCallback.restype = ctypes.c_int
WinBioEnrollCaptureWithCallback.argtypes = [
wintypes.DWORD, # SessionHandle : DWORD
ctypes.c_void_p, # EnrollCallback : PWINBIO_ENROLL_CAPTURE_CALLBACK
ctypes.POINTER(None), # EnrollCallbackContext : void* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('winbio.dll')
WinBioEnrollCaptureWithCallback = Fiddle::Function.new(
lib['WinBioEnrollCaptureWithCallback'],
[
-Fiddle::TYPE_INT, # SessionHandle : DWORD
Fiddle::TYPE_VOIDP, # EnrollCallback : PWINBIO_ENROLL_CAPTURE_CALLBACK
Fiddle::TYPE_VOIDP, # EnrollCallbackContext : void* optional
],
Fiddle::TYPE_INT)#[link(name = "winbio")]
extern "system" {
fn WinBioEnrollCaptureWithCallback(
SessionHandle: u32, // DWORD
EnrollCallback: *const core::ffi::c_void, // PWINBIO_ENROLL_CAPTURE_CALLBACK
EnrollCallbackContext: *mut () // void* optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("winbio.dll")]
public static extern int WinBioEnrollCaptureWithCallback(uint SessionHandle, IntPtr EnrollCallback, IntPtr EnrollCallbackContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winbio_WinBioEnrollCaptureWithCallback' -Namespace Win32 -PassThru
# $api::WinBioEnrollCaptureWithCallback(SessionHandle, EnrollCallback, EnrollCallbackContext)#uselib "winbio.dll"
#func global WinBioEnrollCaptureWithCallback "WinBioEnrollCaptureWithCallback" sptr, sptr, sptr
; WinBioEnrollCaptureWithCallback SessionHandle, EnrollCallback, EnrollCallbackContext ; 戻り値は stat
; SessionHandle : DWORD -> "sptr"
; EnrollCallback : PWINBIO_ENROLL_CAPTURE_CALLBACK -> "sptr"
; EnrollCallbackContext : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "winbio.dll"
#cfunc global WinBioEnrollCaptureWithCallback "WinBioEnrollCaptureWithCallback" int, sptr, sptr
; res = WinBioEnrollCaptureWithCallback(SessionHandle, EnrollCallback, EnrollCallbackContext)
; SessionHandle : DWORD -> "int"
; EnrollCallback : PWINBIO_ENROLL_CAPTURE_CALLBACK -> "sptr"
; EnrollCallbackContext : void* optional -> "sptr"; HRESULT WinBioEnrollCaptureWithCallback(DWORD SessionHandle, PWINBIO_ENROLL_CAPTURE_CALLBACK EnrollCallback, void* EnrollCallbackContext)
#uselib "winbio.dll"
#cfunc global WinBioEnrollCaptureWithCallback "WinBioEnrollCaptureWithCallback" int, intptr, intptr
; res = WinBioEnrollCaptureWithCallback(SessionHandle, EnrollCallback, EnrollCallbackContext)
; SessionHandle : DWORD -> "int"
; EnrollCallback : PWINBIO_ENROLL_CAPTURE_CALLBACK -> "intptr"
; EnrollCallbackContext : void* optional -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winbio = windows.NewLazySystemDLL("winbio.dll")
procWinBioEnrollCaptureWithCallback = winbio.NewProc("WinBioEnrollCaptureWithCallback")
)
// SessionHandle (DWORD), EnrollCallback (PWINBIO_ENROLL_CAPTURE_CALLBACK), EnrollCallbackContext (void* optional)
r1, _, err := procWinBioEnrollCaptureWithCallback.Call(
uintptr(SessionHandle),
uintptr(EnrollCallback),
uintptr(EnrollCallbackContext),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WinBioEnrollCaptureWithCallback(
SessionHandle: DWORD; // DWORD
EnrollCallback: Pointer; // PWINBIO_ENROLL_CAPTURE_CALLBACK
EnrollCallbackContext: Pointer // void* optional
): Integer; stdcall;
external 'winbio.dll' name 'WinBioEnrollCaptureWithCallback';result := DllCall("winbio\WinBioEnrollCaptureWithCallback"
, "UInt", SessionHandle ; DWORD
, "Ptr", EnrollCallback ; PWINBIO_ENROLL_CAPTURE_CALLBACK
, "Ptr", EnrollCallbackContext ; void* optional
, "Int") ; return: HRESULT●WinBioEnrollCaptureWithCallback(SessionHandle, EnrollCallback, EnrollCallbackContext) = DLL("winbio.dll", "int WinBioEnrollCaptureWithCallback(dword, void*, void*)")
# 呼び出し: WinBioEnrollCaptureWithCallback(SessionHandle, EnrollCallback, EnrollCallbackContext)
# SessionHandle : DWORD -> "dword"
# EnrollCallback : PWINBIO_ENROLL_CAPTURE_CALLBACK -> "void*"
# EnrollCallbackContext : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "winbio" fn WinBioEnrollCaptureWithCallback(
SessionHandle: u32, // DWORD
EnrollCallback: ?*anyopaque, // PWINBIO_ENROLL_CAPTURE_CALLBACK
EnrollCallbackContext: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) i32;proc WinBioEnrollCaptureWithCallback(
SessionHandle: uint32, # DWORD
EnrollCallback: pointer, # PWINBIO_ENROLL_CAPTURE_CALLBACK
EnrollCallbackContext: pointer # void* optional
): int32 {.importc: "WinBioEnrollCaptureWithCallback", stdcall, dynlib: "winbio.dll".}pragma(lib, "winbio");
extern(Windows)
int WinBioEnrollCaptureWithCallback(
uint SessionHandle, // DWORD
void* EnrollCallback, // PWINBIO_ENROLL_CAPTURE_CALLBACK
void* EnrollCallbackContext // void* optional
);ccall((:WinBioEnrollCaptureWithCallback, "winbio.dll"), stdcall, Int32,
(UInt32, Ptr{Cvoid}, Ptr{Cvoid}),
SessionHandle, EnrollCallback, EnrollCallbackContext)
# SessionHandle : DWORD -> UInt32
# EnrollCallback : PWINBIO_ENROLL_CAPTURE_CALLBACK -> Ptr{Cvoid}
# EnrollCallbackContext : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WinBioEnrollCaptureWithCallback(
uint32_t SessionHandle,
void* EnrollCallback,
void* EnrollCallbackContext);
]]
local winbio = ffi.load("winbio")
-- winbio.WinBioEnrollCaptureWithCallback(SessionHandle, EnrollCallback, EnrollCallbackContext)
-- SessionHandle : DWORD
-- EnrollCallback : PWINBIO_ENROLL_CAPTURE_CALLBACK
-- EnrollCallbackContext : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('winbio.dll');
const WinBioEnrollCaptureWithCallback = lib.func('__stdcall', 'WinBioEnrollCaptureWithCallback', 'int32_t', ['uint32_t', 'void *', 'void *']);
// WinBioEnrollCaptureWithCallback(SessionHandle, EnrollCallback, EnrollCallbackContext)
// SessionHandle : DWORD -> 'uint32_t'
// EnrollCallback : PWINBIO_ENROLL_CAPTURE_CALLBACK -> 'void *'
// EnrollCallbackContext : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。const lib = Deno.dlopen("winbio.dll", {
WinBioEnrollCaptureWithCallback: { parameters: ["u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WinBioEnrollCaptureWithCallback(SessionHandle, EnrollCallback, EnrollCallbackContext)
// SessionHandle : DWORD -> "u32"
// EnrollCallback : PWINBIO_ENROLL_CAPTURE_CALLBACK -> "pointer"
// EnrollCallbackContext : void* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WinBioEnrollCaptureWithCallback(
uint32_t SessionHandle,
void* EnrollCallback,
void* EnrollCallbackContext);
C, "winbio.dll");
// $ffi->WinBioEnrollCaptureWithCallback(SessionHandle, EnrollCallback, EnrollCallbackContext);
// SessionHandle : DWORD
// EnrollCallback : PWINBIO_ENROLL_CAPTURE_CALLBACK
// EnrollCallbackContext : 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 WinBioEnrollCaptureWithCallback(
int SessionHandle, // DWORD
Callback EnrollCallback, // PWINBIO_ENROLL_CAPTURE_CALLBACK
Pointer EnrollCallbackContext // void* optional
);
}@[Link("winbio")]
lib Libwinbio
fun WinBioEnrollCaptureWithCallback = WinBioEnrollCaptureWithCallback(
SessionHandle : UInt32, # DWORD
EnrollCallback : Void*, # PWINBIO_ENROLL_CAPTURE_CALLBACK
EnrollCallbackContext : 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 WinBioEnrollCaptureWithCallbackNative = Int32 Function(Uint32, Pointer<Void>, Pointer<Void>);
typedef WinBioEnrollCaptureWithCallbackDart = int Function(int, Pointer<Void>, Pointer<Void>);
final WinBioEnrollCaptureWithCallback = DynamicLibrary.open('winbio.dll')
.lookupFunction<WinBioEnrollCaptureWithCallbackNative, WinBioEnrollCaptureWithCallbackDart>('WinBioEnrollCaptureWithCallback');
// SessionHandle : DWORD -> Uint32
// EnrollCallback : PWINBIO_ENROLL_CAPTURE_CALLBACK -> Pointer<Void>
// EnrollCallbackContext : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WinBioEnrollCaptureWithCallback(
SessionHandle: DWORD; // DWORD
EnrollCallback: Pointer; // PWINBIO_ENROLL_CAPTURE_CALLBACK
EnrollCallbackContext: Pointer // void* optional
): Integer; stdcall;
external 'winbio.dll' name 'WinBioEnrollCaptureWithCallback';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WinBioEnrollCaptureWithCallback"
c_WinBioEnrollCaptureWithCallback :: Word32 -> Ptr () -> Ptr () -> IO Int32
-- SessionHandle : DWORD -> Word32
-- EnrollCallback : PWINBIO_ENROLL_CAPTURE_CALLBACK -> Ptr ()
-- EnrollCallbackContext : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let winbioenrollcapturewithcallback =
foreign "WinBioEnrollCaptureWithCallback"
(uint32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* SessionHandle : DWORD -> uint32_t *)
(* EnrollCallback : PWINBIO_ENROLL_CAPTURE_CALLBACK -> (ptr void) *)
(* EnrollCallbackContext : 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 ("WinBioEnrollCaptureWithCallback" win-bio-enroll-capture-with-callback :convention :stdcall) :int32
(session-handle :uint32) ; DWORD
(enroll-callback :pointer) ; PWINBIO_ENROLL_CAPTURE_CALLBACK
(enroll-callback-context :pointer)) ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WinBioEnrollCaptureWithCallback = Win32::API::More->new('winbio',
'int WinBioEnrollCaptureWithCallback(DWORD SessionHandle, LPVOID EnrollCallback, LPVOID EnrollCallbackContext)');
# my $ret = $WinBioEnrollCaptureWithCallback->Call($SessionHandle, $EnrollCallback, $EnrollCallbackContext);
# SessionHandle : DWORD -> DWORD
# EnrollCallback : PWINBIO_ENROLL_CAPTURE_CALLBACK -> LPVOID
# EnrollCallbackContext : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。関連項目
- f WinBioAcquireFocus — 生体認証操作のフォーカスを取得する。
- f WinBioEnrollBegin — 指定ユニットで生体情報の登録処理を開始する。
- f WinBioEnrollCapture — 登録のため生体サンプルを採取する。
- f WinBioEnrollCommit — 採取した生体情報を登録テンプレートとして確定保存する。
- f WinBioEnrollDiscard — 進行中の生体情報登録を破棄する。
- f WinBioReleaseFocus — 取得していた生体認証操作のフォーカスを解放する。