WinBioWait
関数シグネチャ
// winbio.dll
#include <windows.h>
HRESULT WinBioWait(
DWORD SessionHandle
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| SessionHandle | DWORD | in | 開いている生体認証セッションを識別する WINBIO_SESSION_HANDLE 値です。同期セッション ハンドルを開くには、WinBioOpenSession を呼び出します。非同期セッション ハンドルを開くには、WinBioAsyncOpenSession を呼び出します。 |
戻り値の型: HRESULT
公式ドキュメント
セッションで保留中のすべての生体認証操作が完了するか、キャンセルされるまで、呼び出し元の実行をブロックします。Windows 10 ビルド 1607 以降、この関数はモバイル イメージで使用できます。
戻り値
関数が成功した場合は S_OK を返します。関数が失敗した場合は、エラーを示す HRESULT 値を返します。取り得る値には次の表のものが含まれますが、これらに限定されません。一般的なエラー コードの一覧については、Common HRESULT Values を参照してください。
| 戻り値 | 説明 |
|---|---|
| セッション ハンドルが有効ではありません。 |
解説(Remarks)
WinBioWait は、SessionHandle パラメーターに同期セッション ハンドルと非同期セッション ハンドルのどちらを渡した場合でも、呼び出し元のスレッドをブロックします。
非同期セッション ハンドルを使用して呼び出せる他のすべての関数とは異なり、フレームワークは WinBioWait 関数に対して WINBIO_ASYNC_RESULT 構造体を作成しません。
WinBioWait は、コールバック ルーチンのコンテキストから呼び出したり、コールバック ルーチンから間接的に呼び出される可能性のある関数から呼び出したりしないでください。そのようにすると、永続的なデッドロックが発生します。
WinBioWait をウィンドウ プロシージャから呼び出さないでください。そのようにすると、イベント通知が到着するまでユーザー インターフェイスが応答しなくなります。
ウィンドウ メッセージを生成する非同期セッションから WinBioWait を呼び出した場合、ウィンドウ メッセージと待機解除メッセージが到着する順序は保証されません。これらのイベントの順序に依存するコードは記述しないことをお勧めします。
例
次のコード例は、WinBioWait 関数を呼び出して実行をブロックし、非同期スレッドの処理が完了するまで待機する方法を示しています。Winbio.lib 静的ライブラリにリンクし、次のヘッダー ファイルをインクルードしてください。
- Windows.h
- Stdio.h
- Conio.h
- Winbio.h
HRESULT CaptureSampleWithCallback(BOOL bCancel)
{
HRESULT hr = S_OK;
WINBIO_SESSION_HANDLE sessionHandle = NULL;
// システム プールに接続します。
hr = WinBioOpenSession(
WINBIO_TYPE_FINGERPRINT, // サービス プロバイダー
WINBIO_POOL_SYSTEM, // プールの種類
WINBIO_FLAG_RAW, // 生データ アクセス
NULL, // 生体認証ユニット ID の配列
0, // 生体認証ユニット ID の数
WINBIO_DB_DEFAULT, // 既定のデータベース
&sessionHandle // [out] セッション ハンドル
);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioOpenSession failed. hr = 0x%x\n", hr);
goto e_Exit;
}
// 生体認証サンプルを非同期的にキャプチャします。
wprintf_s(L"\n Calling WinBioCaptureSampleWithCallback ");
hr = WinBioCaptureSampleWithCallback(
sessionHandle, // 開いているセッション ハンドル
WINBIO_NO_PURPOSE_AVAILABLE, // サンプルの使用目的
WINBIO_DATA_FLAG_RAW, // サンプルの形式
CaptureSampleCallback, // コールバック関数
NULL // 省略可能なコンテキスト
);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioCaptureSampleWithCallback failed. ");
wprintf_s(L"hr = 0x%x\n", hr);
goto e_Exit;
}
wprintf_s(L"\n Swipe the sensor ...\n");
// bCancel フラグが設定されている場合は識別をキャンセルします。
if (bCancel)
{
wprintf_s(L"\n Starting CANCEL timer...");
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;
}
}
// 非同期の識別処理が完了するか、キャンセルされるまで待機します。
hr = WinBioWait( sessionHandle );
if (FAILED(hr))
{
wprintf_s(L"\n WinBioWait failed. hr = 0x%x\n", hr);
}
e_Exit:
if (sessionHandle != NULL)
{
WinBioCloseSession(sessionHandle);
sessionHandle = NULL;
}
wprintf_s(L"\n Press any key to exit...");
_getch();
return hr;
}
//------------------------------------------------------------------------
// 次の関数は WinBioCaptureSampleWithCallback のコールバックです。
// この関数は生体認証サブシステムからの応答を選別し、
// 結果をコンソール ウィンドウに書き込みます。
//
VOID CALLBACK CaptureSampleCallback(
__in_opt PVOID CaptureCallbackContext,
__in HRESULT OperationStatus,
__in WINBIO_UNIT_ID UnitId,
__in_bcount(SampleSize) PWINBIO_BIR Sample,
__in SIZE_T SampleSize,
__in WINBIO_REJECT_DETAIL RejectDetail
)
{
UNREFERENCED_PARAMETER(CaptureCallbackContext);
wprintf_s(L"\n CaptureSampleCallback executing");
wprintf_s(L"\n Swipe processed - Unit ID: %d", UnitId);
if (FAILED(OperationStatus))
{
if (OperationStatus == WINBIO_E_BAD_CAPTURE)
{
wprintf_s(L"\n Bad capture; reason: %d\n", RejectDetail);
}
else
{
wprintf_s(L"\n WinBioCaptureSampleWithCallback failed. ");
wprintf_s(L" OperationStatus = 0x%x\n", OperationStatus);
}
goto e_Exit;
}
wprintf_s(L"\n Captured %d bytes.\n", SampleSize);
e_Exit:
if (Sample != NULL)
{
WinBioFree(Sample);
Sample = NULL;
}
}
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// winbio.dll
#include <windows.h>
HRESULT WinBioWait(
DWORD SessionHandle
);[DllImport("winbio.dll", ExactSpelling = true)]
static extern int WinBioWait(
uint SessionHandle // DWORD
);<DllImport("winbio.dll", ExactSpelling:=True)>
Public Shared Function WinBioWait(
SessionHandle As UInteger ' DWORD
) As Integer
End Function' SessionHandle : DWORD
Declare PtrSafe Function WinBioWait Lib "winbio" ( _
ByVal SessionHandle As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WinBioWait = ctypes.windll.winbio.WinBioWait
WinBioWait.restype = ctypes.c_int
WinBioWait.argtypes = [
wintypes.DWORD, # SessionHandle : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('winbio.dll')
WinBioWait = Fiddle::Function.new(
lib['WinBioWait'],
[
-Fiddle::TYPE_INT, # SessionHandle : DWORD
],
Fiddle::TYPE_INT)#[link(name = "winbio")]
extern "system" {
fn WinBioWait(
SessionHandle: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("winbio.dll")]
public static extern int WinBioWait(uint SessionHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winbio_WinBioWait' -Namespace Win32 -PassThru
# $api::WinBioWait(SessionHandle)#uselib "winbio.dll"
#func global WinBioWait "WinBioWait" sptr
; WinBioWait SessionHandle ; 戻り値は stat
; SessionHandle : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "winbio.dll"
#cfunc global WinBioWait "WinBioWait" int
; res = WinBioWait(SessionHandle)
; SessionHandle : DWORD -> "int"; HRESULT WinBioWait(DWORD SessionHandle)
#uselib "winbio.dll"
#cfunc global WinBioWait "WinBioWait" int
; res = WinBioWait(SessionHandle)
; SessionHandle : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winbio = windows.NewLazySystemDLL("winbio.dll")
procWinBioWait = winbio.NewProc("WinBioWait")
)
// SessionHandle (DWORD)
r1, _, err := procWinBioWait.Call(
uintptr(SessionHandle),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WinBioWait(
SessionHandle: DWORD // DWORD
): Integer; stdcall;
external 'winbio.dll' name 'WinBioWait';result := DllCall("winbio\WinBioWait"
, "UInt", SessionHandle ; DWORD
, "Int") ; return: HRESULT●WinBioWait(SessionHandle) = DLL("winbio.dll", "int WinBioWait(dword)")
# 呼び出し: WinBioWait(SessionHandle)
# SessionHandle : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "winbio" fn WinBioWait(
SessionHandle: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc WinBioWait(
SessionHandle: uint32 # DWORD
): int32 {.importc: "WinBioWait", stdcall, dynlib: "winbio.dll".}pragma(lib, "winbio");
extern(Windows)
int WinBioWait(
uint SessionHandle // DWORD
);ccall((:WinBioWait, "winbio.dll"), stdcall, Int32,
(UInt32,),
SessionHandle)
# SessionHandle : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WinBioWait(
uint32_t SessionHandle);
]]
local winbio = ffi.load("winbio")
-- winbio.WinBioWait(SessionHandle)
-- SessionHandle : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('winbio.dll');
const WinBioWait = lib.func('__stdcall', 'WinBioWait', 'int32_t', ['uint32_t']);
// WinBioWait(SessionHandle)
// SessionHandle : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("winbio.dll", {
WinBioWait: { parameters: ["u32"], result: "i32" },
});
// lib.symbols.WinBioWait(SessionHandle)
// SessionHandle : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WinBioWait(
uint32_t SessionHandle);
C, "winbio.dll");
// $ffi->WinBioWait(SessionHandle);
// SessionHandle : DWORD
// 構造体/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 WinBioWait(
int SessionHandle // DWORD
);
}@[Link("winbio")]
lib Libwinbio
fun WinBioWait = WinBioWait(
SessionHandle : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WinBioWaitNative = Int32 Function(Uint32);
typedef WinBioWaitDart = int Function(int);
final WinBioWait = DynamicLibrary.open('winbio.dll')
.lookupFunction<WinBioWaitNative, WinBioWaitDart>('WinBioWait');
// SessionHandle : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WinBioWait(
SessionHandle: DWORD // DWORD
): Integer; stdcall;
external 'winbio.dll' name 'WinBioWait';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WinBioWait"
c_WinBioWait :: Word32 -> IO Int32
-- SessionHandle : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let winbiowait =
foreign "WinBioWait"
(uint32_t @-> returning int32_t)
(* SessionHandle : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library winbio (t "winbio.dll"))
(cffi:use-foreign-library winbio)
(cffi:defcfun ("WinBioWait" win-bio-wait :convention :stdcall) :int32
(session-handle :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WinBioWait = Win32::API::More->new('winbio',
'int WinBioWait(DWORD SessionHandle)');
# my $ret = $WinBioWait->Call($SessionHandle);
# SessionHandle : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f WinBioCaptureSampleWithCallback — コールバック方式で生体サンプルを採取する。
- f WinBioEnrollCaptureWithCallback — コールバック方式で登録用の生体サンプルを採取する。
- f WinBioIdentifyWithCallback — コールバック方式で生体情報から利用者を識別する。
- f WinBioLocateSensorWithCallback — コールバック方式で対象の生体センサーを特定する。
- f WinBioVerifyWithCallback — コールバック方式で生体情報の本人確認検証を行う。