WinBioEnrollCommit
関数シグネチャ
// winbio.dll
#include <windows.h>
HRESULT WinBioEnrollCommit(
DWORD SessionHandle,
WINBIO_IDENTITY* Identity, // optional
BYTE* IsNewTemplate // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| SessionHandle | DWORD | in | オープンされている生体認証セッションを識別する WINBIO_SESSION_HANDLE 値です。同期セッションハンドルは WinBioOpenSession を呼び出して開きます。非同期セッションハンドルは WinBioAsyncOpenSession を呼び出して開きます。 |
| Identity | WINBIO_IDENTITY* | outoptional | テンプレートの識別子 (GUID または SID) を受け取る WINBIO_IDENTITY 構造体へのポインターです。 |
| IsNewTemplate | BYTE* | outoptional | データベースに追加されるテンプレートが新規かどうかを示すブール値へのポインターです。 |
戻り値の型: HRESULT
公式ドキュメント
保留中の生体認証テンプレートを確定し、登録に使用した生体認証ユニットに関連付けられたデータベースに保存します。Windows 10 ビルド 1607 以降、この関数はモバイルイメージで使用できます。
戻り値
関数が成功した場合は S_OK を返します。失敗した場合は、エラーを示す HRESULT 値を返します。返される可能性のある値には次の表のものが含まれますが、これらに限定されません。一般的なエラーコードの一覧については、Common HRESULT Values を参照してください。
| リターンコード | 説明 |
|---|---|
| セッションハンドルが有効ではありません。 | |
| Identity パラメーターおよび IsNewTemplate パラメーターで指定するポインターを NULL にすることはできません。 | |
| データベースにテンプレートを格納する空き領域がありません。 | |
| このテンプレートは、別の ID またはサブファクターでデータベースに既に保存されているテンプレートと一致します (システムプールのみ)。 | |
| 生体認証ユニットが使用中でロックされています。 |
解説(Remarks)
保留中のテンプレートがデータベースに既に存在するテンプレートと重複している場合、Identity パラメーターは既存のテンプレートを指し、IsNewTemplate パラメーターが指す値は FALSE になります。
WinBioEnrollCommit 関数が成功すると、次のレジストリ値が 0x01 に設定されます。
HKEY_LOCAL_MACHINE
System
CurrentControlSet
Services
WbioSrvc
Parameters
EnrollmentCommitted
WinBioEnrollCommit を非同期的に使用するには、WinBioAsyncOpenSession を呼び出して作成したセッションハンドルを指定して、この関数を呼び出します。フレームワークは WINBIO_ASYNC_RESULT 構造体を割り当て、それを使用して操作の成否に関する情報を返します。操作が成功した場合、フレームワークは入れ子になった EnrollCommit 構造体に WINBIO_IDENTITY 情報と、テンプレートが新規かどうかを示すフラグを格納して返します。操作が失敗した場合、フレームワークはエラー情報を返します。WINBIO_ASYNC_RESULT 構造体は、WinBioAsyncOpenSession 関数の NotificationMethod パラメーターに設定した値に応じて、アプリケーションのコールバックまたはアプリケーションのメッセージキューに返されます。
- コールバックを使用して完了通知を受け取る場合は、PWINBIO_ASYNC_COMPLETION_CALLBACK 関数を実装し、NotificationMethod パラメーターに WINBIO_ASYNC_NOTIFY_CALLBACK を設定する必要があります。
- アプリケーションのメッセージキューを使用して完了通知を受け取る場合は、NotificationMethod パラメーターに WINBIO_ASYNC_NOTIFY_MESSAGE を設定する必要があります。フレームワークは、ウィンドウメッセージの LPARAM フィールドに WINBIO_ASYNC_RESULT ポインターを返します。
例
次の関数は、WinBioEnrollCommit を呼び出して生体認証の登録をシステムプールにコミットします。Winbio.lib スタティックライブラリをリンクし、次のヘッダーファイルをインクルードしてください。
- Windows.h
- Stdio.h
- Conio.h
- Winbio.h
HRESULT EnrollSysPool(
BOOL discardEnrollment,
WINBIO_BIOMETRIC_SUBTYPE subFactor)
{
HRESULT hr = S_OK;
WINBIO_IDENTITY identity = {0};
WINBIO_SESSION_HANDLE sessionHandle = NULL;
WINBIO_UNIT_ID unitId = 0;
WINBIO_REJECT_DETAIL rejectDetail = 0;
BOOLEAN isNewTemplate = TRUE;
// システムプールに接続します。
hr = WinBioOpenSession(
WINBIO_TYPE_FINGERPRINT, // サービスプロバイダー
WINBIO_POOL_SYSTEM, // プールの種類
WINBIO_FLAG_DEFAULT, // 構成とアクセス
NULL, // 生体認証ユニット ID の配列
0, // 生体認証ユニット ID の数
NULL, // データベース ID
&sessionHandle // [out] セッションハンドル
);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioOpenSession failed. ");
wprintf_s(L"hr = 0x%x\n", hr);
goto e_Exit;
}
// センサーを検出します。
wprintf_s(L"\n Swipe your finger on the sensor...\n");
hr = WinBioLocateSensor( sessionHandle, &unitId);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioLocateSensor failed. hr = 0x%x\n", hr);
goto e_Exit;
}
// 登録シーケンスを開始します。
wprintf_s(L"\n Starting enrollment sequence...\n");
hr = WinBioEnrollBegin(
sessionHandle, // オープン済みの生体認証セッションのハンドル
subFactor, // テンプレートを作成する対象の指
unitId // 生体認証ユニット ID
);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioEnrollBegin failed. hr = 0x%x\n", hr);
goto e_Exit;
}
// WinBioEnrollBegin 関数の subFactor 引数で指定した指で
// センサーをスワイプして、登録情報をキャプチャします。
for (int swipeCount = 1;; ++swipeCount)
{
wprintf_s(L"\n Swipe the sensor to capture %s sample.",
(swipeCount == 1)?L"the first":L"another");
hr = WinBioEnrollCapture(
sessionHandle, // オープン済みの生体認証セッションのハンドル
&rejectDetail // [out] 失敗情報
);
wprintf_s(L"\n Sample %d captured from unit number %d.",
swipeCount,
unitId);
if (hr == WINBIO_I_MORE_DATA)
{
wprintf_s(L"\n More data required.\n");
continue;
}
if (FAILED(hr))
{
if (hr == WINBIO_E_BAD_CAPTURE)
{
wprintf_s(L"\n Error: Bad capture; reason: %d",
rejectDetail);
continue;
}
else
{
wprintf_s(L"\n WinBioEnrollCapture failed. hr = 0x%x", hr);
goto e_Exit;
}
}
else
{
wprintf_s(L"\n Template completed.\n");
break;
}
}
// 対応するフラグが設定されている場合は登録を破棄します。
// 破棄しない場合は登録をコミットします。
if (discardEnrollment == TRUE)
{
wprintf_s(L"\n Discarding enrollment...\n\n");
hr = WinBioEnrollDiscard( sessionHandle );
if (FAILED(hr))
{
wprintf_s(L"\n WinBioLocateSensor failed. hr = 0x%x\n", hr);
}
goto e_Exit;
}
else
{
wprintf_s(L"\n Committing enrollment...\n");
hr = WinBioEnrollCommit(
sessionHandle, // オープン済みの生体認証セッションのハンドル
&identity, // ユーザーの WINBIO_IDENTITY オブジェクト
&isNewTemplate); // 新しいテンプレートかどうか
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" Press any key to continue...");
_getch();
return hr;
}
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// winbio.dll
#include <windows.h>
HRESULT WinBioEnrollCommit(
DWORD SessionHandle,
WINBIO_IDENTITY* Identity, // optional
BYTE* IsNewTemplate // optional
);[DllImport("winbio.dll", ExactSpelling = true)]
static extern int WinBioEnrollCommit(
uint SessionHandle, // DWORD
IntPtr Identity, // WINBIO_IDENTITY* optional, out
IntPtr IsNewTemplate // BYTE* optional, out
);<DllImport("winbio.dll", ExactSpelling:=True)>
Public Shared Function WinBioEnrollCommit(
SessionHandle As UInteger, ' DWORD
Identity As IntPtr, ' WINBIO_IDENTITY* optional, out
IsNewTemplate As IntPtr ' BYTE* optional, out
) As Integer
End Function' SessionHandle : DWORD
' Identity : WINBIO_IDENTITY* optional, out
' IsNewTemplate : BYTE* optional, out
Declare PtrSafe Function WinBioEnrollCommit Lib "winbio" ( _
ByVal SessionHandle As Long, _
ByVal Identity As LongPtr, _
ByVal IsNewTemplate As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WinBioEnrollCommit = ctypes.windll.winbio.WinBioEnrollCommit
WinBioEnrollCommit.restype = ctypes.c_int
WinBioEnrollCommit.argtypes = [
wintypes.DWORD, # SessionHandle : DWORD
ctypes.c_void_p, # Identity : WINBIO_IDENTITY* optional, out
ctypes.POINTER(ctypes.c_ubyte), # IsNewTemplate : BYTE* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('winbio.dll')
WinBioEnrollCommit = Fiddle::Function.new(
lib['WinBioEnrollCommit'],
[
-Fiddle::TYPE_INT, # SessionHandle : DWORD
Fiddle::TYPE_VOIDP, # Identity : WINBIO_IDENTITY* optional, out
Fiddle::TYPE_VOIDP, # IsNewTemplate : BYTE* optional, out
],
Fiddle::TYPE_INT)#[link(name = "winbio")]
extern "system" {
fn WinBioEnrollCommit(
SessionHandle: u32, // DWORD
Identity: *mut WINBIO_IDENTITY, // WINBIO_IDENTITY* optional, out
IsNewTemplate: *mut u8 // BYTE* optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("winbio.dll")]
public static extern int WinBioEnrollCommit(uint SessionHandle, IntPtr Identity, IntPtr IsNewTemplate);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winbio_WinBioEnrollCommit' -Namespace Win32 -PassThru
# $api::WinBioEnrollCommit(SessionHandle, Identity, IsNewTemplate)#uselib "winbio.dll"
#func global WinBioEnrollCommit "WinBioEnrollCommit" sptr, sptr, sptr
; WinBioEnrollCommit SessionHandle, varptr(Identity), varptr(IsNewTemplate) ; 戻り値は stat
; SessionHandle : DWORD -> "sptr"
; Identity : WINBIO_IDENTITY* optional, out -> "sptr"
; IsNewTemplate : BYTE* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "winbio.dll" #cfunc global WinBioEnrollCommit "WinBioEnrollCommit" int, var, var ; res = WinBioEnrollCommit(SessionHandle, Identity, IsNewTemplate) ; SessionHandle : DWORD -> "int" ; Identity : WINBIO_IDENTITY* optional, out -> "var" ; IsNewTemplate : BYTE* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "winbio.dll" #cfunc global WinBioEnrollCommit "WinBioEnrollCommit" int, sptr, sptr ; res = WinBioEnrollCommit(SessionHandle, varptr(Identity), varptr(IsNewTemplate)) ; SessionHandle : DWORD -> "int" ; Identity : WINBIO_IDENTITY* optional, out -> "sptr" ; IsNewTemplate : BYTE* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; HRESULT WinBioEnrollCommit(DWORD SessionHandle, WINBIO_IDENTITY* Identity, BYTE* IsNewTemplate) #uselib "winbio.dll" #cfunc global WinBioEnrollCommit "WinBioEnrollCommit" int, var, var ; res = WinBioEnrollCommit(SessionHandle, Identity, IsNewTemplate) ; SessionHandle : DWORD -> "int" ; Identity : WINBIO_IDENTITY* optional, out -> "var" ; IsNewTemplate : BYTE* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WinBioEnrollCommit(DWORD SessionHandle, WINBIO_IDENTITY* Identity, BYTE* IsNewTemplate) #uselib "winbio.dll" #cfunc global WinBioEnrollCommit "WinBioEnrollCommit" int, intptr, intptr ; res = WinBioEnrollCommit(SessionHandle, varptr(Identity), varptr(IsNewTemplate)) ; SessionHandle : DWORD -> "int" ; Identity : WINBIO_IDENTITY* optional, out -> "intptr" ; IsNewTemplate : BYTE* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winbio = windows.NewLazySystemDLL("winbio.dll")
procWinBioEnrollCommit = winbio.NewProc("WinBioEnrollCommit")
)
// SessionHandle (DWORD), Identity (WINBIO_IDENTITY* optional, out), IsNewTemplate (BYTE* optional, out)
r1, _, err := procWinBioEnrollCommit.Call(
uintptr(SessionHandle),
uintptr(Identity),
uintptr(IsNewTemplate),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WinBioEnrollCommit(
SessionHandle: DWORD; // DWORD
Identity: Pointer; // WINBIO_IDENTITY* optional, out
IsNewTemplate: Pointer // BYTE* optional, out
): Integer; stdcall;
external 'winbio.dll' name 'WinBioEnrollCommit';result := DllCall("winbio\WinBioEnrollCommit"
, "UInt", SessionHandle ; DWORD
, "Ptr", Identity ; WINBIO_IDENTITY* optional, out
, "Ptr", IsNewTemplate ; BYTE* optional, out
, "Int") ; return: HRESULT●WinBioEnrollCommit(SessionHandle, Identity, IsNewTemplate) = DLL("winbio.dll", "int WinBioEnrollCommit(dword, void*, void*)")
# 呼び出し: WinBioEnrollCommit(SessionHandle, Identity, IsNewTemplate)
# SessionHandle : DWORD -> "dword"
# Identity : WINBIO_IDENTITY* optional, out -> "void*"
# IsNewTemplate : BYTE* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "winbio" fn WinBioEnrollCommit(
SessionHandle: u32, // DWORD
Identity: [*c]WINBIO_IDENTITY, // WINBIO_IDENTITY* optional, out
IsNewTemplate: [*c]u8 // BYTE* optional, out
) callconv(std.os.windows.WINAPI) i32;proc WinBioEnrollCommit(
SessionHandle: uint32, # DWORD
Identity: ptr WINBIO_IDENTITY, # WINBIO_IDENTITY* optional, out
IsNewTemplate: ptr uint8 # BYTE* optional, out
): int32 {.importc: "WinBioEnrollCommit", stdcall, dynlib: "winbio.dll".}pragma(lib, "winbio");
extern(Windows)
int WinBioEnrollCommit(
uint SessionHandle, // DWORD
WINBIO_IDENTITY* Identity, // WINBIO_IDENTITY* optional, out
ubyte* IsNewTemplate // BYTE* optional, out
);ccall((:WinBioEnrollCommit, "winbio.dll"), stdcall, Int32,
(UInt32, Ptr{WINBIO_IDENTITY}, Ptr{UInt8}),
SessionHandle, Identity, IsNewTemplate)
# SessionHandle : DWORD -> UInt32
# Identity : WINBIO_IDENTITY* optional, out -> Ptr{WINBIO_IDENTITY}
# IsNewTemplate : BYTE* optional, out -> Ptr{UInt8}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WinBioEnrollCommit(
uint32_t SessionHandle,
void* Identity,
uint8_t* IsNewTemplate);
]]
local winbio = ffi.load("winbio")
-- winbio.WinBioEnrollCommit(SessionHandle, Identity, IsNewTemplate)
-- SessionHandle : DWORD
-- Identity : WINBIO_IDENTITY* optional, out
-- IsNewTemplate : BYTE* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('winbio.dll');
const WinBioEnrollCommit = lib.func('__stdcall', 'WinBioEnrollCommit', 'int32_t', ['uint32_t', 'void *', 'uint8_t *']);
// WinBioEnrollCommit(SessionHandle, Identity, IsNewTemplate)
// SessionHandle : DWORD -> 'uint32_t'
// Identity : WINBIO_IDENTITY* optional, out -> 'void *'
// IsNewTemplate : BYTE* optional, out -> 'uint8_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("winbio.dll", {
WinBioEnrollCommit: { parameters: ["u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WinBioEnrollCommit(SessionHandle, Identity, IsNewTemplate)
// SessionHandle : DWORD -> "u32"
// Identity : WINBIO_IDENTITY* optional, out -> "pointer"
// IsNewTemplate : BYTE* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WinBioEnrollCommit(
uint32_t SessionHandle,
void* Identity,
uint8_t* IsNewTemplate);
C, "winbio.dll");
// $ffi->WinBioEnrollCommit(SessionHandle, Identity, IsNewTemplate);
// SessionHandle : DWORD
// Identity : WINBIO_IDENTITY* optional, out
// IsNewTemplate : BYTE* optional, out
// 構造体/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 WinBioEnrollCommit(
int SessionHandle, // DWORD
Pointer Identity, // WINBIO_IDENTITY* optional, out
byte[] IsNewTemplate // BYTE* optional, out
);
}@[Link("winbio")]
lib Libwinbio
fun WinBioEnrollCommit = WinBioEnrollCommit(
SessionHandle : UInt32, # DWORD
Identity : WINBIO_IDENTITY*, # WINBIO_IDENTITY* optional, out
IsNewTemplate : UInt8* # BYTE* optional, out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WinBioEnrollCommitNative = Int32 Function(Uint32, Pointer<Void>, Pointer<Uint8>);
typedef WinBioEnrollCommitDart = int Function(int, Pointer<Void>, Pointer<Uint8>);
final WinBioEnrollCommit = DynamicLibrary.open('winbio.dll')
.lookupFunction<WinBioEnrollCommitNative, WinBioEnrollCommitDart>('WinBioEnrollCommit');
// SessionHandle : DWORD -> Uint32
// Identity : WINBIO_IDENTITY* optional, out -> Pointer<Void>
// IsNewTemplate : BYTE* optional, out -> Pointer<Uint8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WinBioEnrollCommit(
SessionHandle: DWORD; // DWORD
Identity: Pointer; // WINBIO_IDENTITY* optional, out
IsNewTemplate: Pointer // BYTE* optional, out
): Integer; stdcall;
external 'winbio.dll' name 'WinBioEnrollCommit';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WinBioEnrollCommit"
c_WinBioEnrollCommit :: Word32 -> Ptr () -> Ptr Word8 -> IO Int32
-- SessionHandle : DWORD -> Word32
-- Identity : WINBIO_IDENTITY* optional, out -> Ptr ()
-- IsNewTemplate : BYTE* optional, out -> Ptr Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let winbioenrollcommit =
foreign "WinBioEnrollCommit"
(uint32_t @-> (ptr void) @-> (ptr uint8_t) @-> returning int32_t)
(* SessionHandle : DWORD -> uint32_t *)
(* Identity : WINBIO_IDENTITY* optional, out -> (ptr void) *)
(* IsNewTemplate : BYTE* optional, out -> (ptr uint8_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library winbio (t "winbio.dll"))
(cffi:use-foreign-library winbio)
(cffi:defcfun ("WinBioEnrollCommit" win-bio-enroll-commit :convention :stdcall) :int32
(session-handle :uint32) ; DWORD
(identity :pointer) ; WINBIO_IDENTITY* optional, out
(is-new-template :pointer)) ; BYTE* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WinBioEnrollCommit = Win32::API::More->new('winbio',
'int WinBioEnrollCommit(DWORD SessionHandle, LPVOID Identity, LPVOID IsNewTemplate)');
# my $ret = $WinBioEnrollCommit->Call($SessionHandle, $Identity, $IsNewTemplate);
# SessionHandle : DWORD -> DWORD
# Identity : WINBIO_IDENTITY* optional, out -> LPVOID
# IsNewTemplate : BYTE* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f WinBioEnrollBegin — 指定ユニットで生体情報の登録処理を開始する。
- f WinBioEnrollCapture — 登録のため生体サンプルを採取する。
- f WinBioEnrollCaptureWithCallback — コールバック方式で登録用の生体サンプルを採取する。
- f WinBioEnrollDiscard — 進行中の生体情報登録を破棄する。