WinBioCloseSession
関数シグネチャ
// winbio.dll
#include <windows.h>
HRESULT WinBioCloseSession(
DWORD SessionHandle
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| SessionHandle | DWORD | in | 開いているバイオメトリックセッションを識別する WINBIO_SESSION_HANDLE 値です。同期セッションハンドルを開くには、WinBioOpenSession を呼び出します。非同期セッションハンドルを開くには、WinBioAsyncOpenSession を呼び出します。 |
戻り値の型: HRESULT
公式ドキュメント
バイオメトリックセッションを閉じ、関連付けられたリソースを解放します。Windows 10 ビルド 1607 以降、この関数はモバイルイメージで使用できます。
戻り値
関数が成功した場合は S_OK を返します。関数が失敗した場合は、エラーを示す HRESULT 値を返します。返される値には次の表に示すものが含まれますが、これらに限定されません。一般的なエラーコードの一覧については、Common HRESULT Values を参照してください。
| 戻り値 | 説明 |
|---|---|
| セッションハンドルが有効ではありません。 |
解説(Remarks)
WinBioCloseSession を同期的に使用するには、WinBioOpenSession を呼び出して作成したセッションハンドルを指定してこの関数を呼び出します。この関数は、操作が完了するかエラーが発生するまでブロックします。
WinBioCloseSession を非同期的に使用するには、WinBioAsyncOpenSession を呼び出して作成したセッションハンドルを指定してこの関数を呼び出します。フレームワークは WINBIO_ASYNC_RESULT 構造体を割り当て、それを使用して操作の成否に関する情報を返します。WINBIO_ASYNC_RESULT 構造体は、WinBioAsyncOpenSession 関数の NotificationMethod パラメーターに設定した値に応じて、アプリケーションのコールバックまたはアプリケーションのメッセージキューに返されます。
- コールバックを使用して完了通知を受け取る場合は、PWINBIO_ASYNC_COMPLETION_CALLBACK 関数を実装し、NotificationMethod パラメーターに WINBIO_ASYNC_NOTIFY_CALLBACK を設定する必要があります。
- アプリケーションのメッセージキューを使用して完了通知を受け取る場合は、NotificationMethod パラメーターに WINBIO_ASYNC_NOTIFY_MESSAGE を設定する必要があります。フレームワークは、ウィンドウメッセージの LPARAM フィールドに WINBIO_ASYNC_RESULT ポインターを返します。
例
次の関数は、テンプレートに登録されているバイオメトリックのサブファクターを列挙する方法を示します。このサンプルはシステムプールへの接続を作成し、クリーンアップ時に WinBioCloseSession を呼び出すまで接続を開いたままにします。Winbio.lib スタティックライブラリをリンクし、次のヘッダーファイルをインクルードしてください。
- Windows.h
- Stdio.h
- Conio.h
- Winbio.h
HRESULT EnumEnrollments( )
{
// Declare variables.
HRESULT hr = S_OK;
WINBIO_IDENTITY identity = {0};
WINBIO_SESSION_HANDLE sessionHandle = NULL;
WINBIO_UNIT_ID unitId = 0;
PWINBIO_BIOMETRIC_SUBTYPE subFactorArray = NULL;
WINBIO_BIOMETRIC_SUBTYPE SubFactor = 0;
SIZE_T subFactorCount = 0;
WINBIO_REJECT_DETAIL rejectDetail = 0;
WINBIO_BIOMETRIC_SUBTYPE subFactor = WINBIO_SUBTYPE_NO_INFORMATION;
// 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;
}
// Locate the biometric sensor and retrieve a WINBIO_IDENTITY object.
wprintf_s(L"\n Calling WinBioIdentify - Swipe finger on sensor...\n");
hr = WinBioIdentify(
sessionHandle, // Session handle
&unitId, // Biometric unit ID
&identity, // User SID
&subFactor, // Finger sub factor
&rejectDetail // Rejection information
);
wprintf_s(L"\n Swipe processed - Unit ID: %d\n", unitId);
if (FAILED(hr))
{
if (hr == WINBIO_E_UNKNOWN_ID)
{
wprintf_s(L"\n Unknown identity.\n");
}
else if (hr == WINBIO_E_BAD_CAPTURE)
{
wprintf_s(L"\n Bad capture; reason: %d\n", rejectDetail);
}
else
{
wprintf_s(L"\n WinBioEnumBiometricUnits failed. hr = 0x%x\n", hr);
}
goto e_Exit;
}
// Retrieve the biometric sub-factors for the template.
hr = WinBioEnumEnrollments(
sessionHandle, // Session handle
unitId, // Biometric unit ID
&identity, // Template ID
&subFactorArray, // Subfactors
&subFactorCount // Count of subfactors
);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioEnumEnrollments failed. hr = 0x%x\n", hr);
goto e_Exit;
}
// Print the sub-factor(s) to the console.
wprintf_s(L"\n Enrollments for this user on Unit ID %d:", unitId);
for (SIZE_T index = 0; index < subFactorCount; ++index)
{
SubFactor = subFactorArray[index];
switch (SubFactor)
{
case WINBIO_ANSI_381_POS_RH_THUMB:
wprintf_s(L"\n RH thumb\n");
break;
case WINBIO_ANSI_381_POS_RH_INDEX_FINGER:
wprintf_s(L"\n RH index finger\n");
break;
case WINBIO_ANSI_381_POS_RH_MIDDLE_FINGER:
wprintf_s(L"\n RH middle finger\n");
break;
case WINBIO_ANSI_381_POS_RH_RING_FINGER:
wprintf_s(L"\n RH ring finger\n");
break;
case WINBIO_ANSI_381_POS_RH_LITTLE_FINGER:
wprintf_s(L"\n RH little finger\n");
break;
case WINBIO_ANSI_381_POS_LH_THUMB:
wprintf_s(L"\n LH thumb\n");
break;
case WINBIO_ANSI_381_POS_LH_INDEX_FINGER:
wprintf_s(L"\n LH index finger\n");
break;
case WINBIO_ANSI_381_POS_LH_MIDDLE_FINGER:
wprintf_s(L"\n LH middle finger\n");
break;
case WINBIO_ANSI_381_POS_LH_RING_FINGER:
wprintf_s(L"\n LH ring finger\n");
break;
case WINBIO_ANSI_381_POS_LH_LITTLE_FINGER:
wprintf_s(L"\n LH little finger\n");
break;
default:
wprintf_s(L"\n The sub-factor is not correct\n");
break;
}
}
e_Exit:
if (subFactorArray!= NULL)
{
WinBioFree(subFactorArray);
subFactorArray = NULL;
}
if (sessionHandle != NULL)
{
WinBioCloseSession(sessionHandle);
sessionHandle = NULL;
}
wprintf_s(L"\n Press any key to exit...");
_getch();
return hr;
}
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// winbio.dll
#include <windows.h>
HRESULT WinBioCloseSession(
DWORD SessionHandle
);[DllImport("winbio.dll", ExactSpelling = true)]
static extern int WinBioCloseSession(
uint SessionHandle // DWORD
);<DllImport("winbio.dll", ExactSpelling:=True)>
Public Shared Function WinBioCloseSession(
SessionHandle As UInteger ' DWORD
) As Integer
End Function' SessionHandle : DWORD
Declare PtrSafe Function WinBioCloseSession 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
WinBioCloseSession = ctypes.windll.winbio.WinBioCloseSession
WinBioCloseSession.restype = ctypes.c_int
WinBioCloseSession.argtypes = [
wintypes.DWORD, # SessionHandle : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('winbio.dll')
WinBioCloseSession = Fiddle::Function.new(
lib['WinBioCloseSession'],
[
-Fiddle::TYPE_INT, # SessionHandle : DWORD
],
Fiddle::TYPE_INT)#[link(name = "winbio")]
extern "system" {
fn WinBioCloseSession(
SessionHandle: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("winbio.dll")]
public static extern int WinBioCloseSession(uint SessionHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winbio_WinBioCloseSession' -Namespace Win32 -PassThru
# $api::WinBioCloseSession(SessionHandle)#uselib "winbio.dll"
#func global WinBioCloseSession "WinBioCloseSession" sptr
; WinBioCloseSession SessionHandle ; 戻り値は stat
; SessionHandle : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "winbio.dll"
#cfunc global WinBioCloseSession "WinBioCloseSession" int
; res = WinBioCloseSession(SessionHandle)
; SessionHandle : DWORD -> "int"; HRESULT WinBioCloseSession(DWORD SessionHandle)
#uselib "winbio.dll"
#cfunc global WinBioCloseSession "WinBioCloseSession" int
; res = WinBioCloseSession(SessionHandle)
; SessionHandle : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winbio = windows.NewLazySystemDLL("winbio.dll")
procWinBioCloseSession = winbio.NewProc("WinBioCloseSession")
)
// SessionHandle (DWORD)
r1, _, err := procWinBioCloseSession.Call(
uintptr(SessionHandle),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WinBioCloseSession(
SessionHandle: DWORD // DWORD
): Integer; stdcall;
external 'winbio.dll' name 'WinBioCloseSession';result := DllCall("winbio\WinBioCloseSession"
, "UInt", SessionHandle ; DWORD
, "Int") ; return: HRESULT●WinBioCloseSession(SessionHandle) = DLL("winbio.dll", "int WinBioCloseSession(dword)")
# 呼び出し: WinBioCloseSession(SessionHandle)
# SessionHandle : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "winbio" fn WinBioCloseSession(
SessionHandle: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc WinBioCloseSession(
SessionHandle: uint32 # DWORD
): int32 {.importc: "WinBioCloseSession", stdcall, dynlib: "winbio.dll".}pragma(lib, "winbio");
extern(Windows)
int WinBioCloseSession(
uint SessionHandle // DWORD
);ccall((:WinBioCloseSession, "winbio.dll"), stdcall, Int32,
(UInt32,),
SessionHandle)
# SessionHandle : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WinBioCloseSession(
uint32_t SessionHandle);
]]
local winbio = ffi.load("winbio")
-- winbio.WinBioCloseSession(SessionHandle)
-- SessionHandle : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('winbio.dll');
const WinBioCloseSession = lib.func('__stdcall', 'WinBioCloseSession', 'int32_t', ['uint32_t']);
// WinBioCloseSession(SessionHandle)
// SessionHandle : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("winbio.dll", {
WinBioCloseSession: { parameters: ["u32"], result: "i32" },
});
// lib.symbols.WinBioCloseSession(SessionHandle)
// SessionHandle : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WinBioCloseSession(
uint32_t SessionHandle);
C, "winbio.dll");
// $ffi->WinBioCloseSession(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 WinBioCloseSession(
int SessionHandle // DWORD
);
}@[Link("winbio")]
lib Libwinbio
fun WinBioCloseSession = WinBioCloseSession(
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 WinBioCloseSessionNative = Int32 Function(Uint32);
typedef WinBioCloseSessionDart = int Function(int);
final WinBioCloseSession = DynamicLibrary.open('winbio.dll')
.lookupFunction<WinBioCloseSessionNative, WinBioCloseSessionDart>('WinBioCloseSession');
// SessionHandle : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WinBioCloseSession(
SessionHandle: DWORD // DWORD
): Integer; stdcall;
external 'winbio.dll' name 'WinBioCloseSession';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WinBioCloseSession"
c_WinBioCloseSession :: Word32 -> IO Int32
-- SessionHandle : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let winbioclosesession =
foreign "WinBioCloseSession"
(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 ("WinBioCloseSession" win-bio-close-session :convention :stdcall) :int32
(session-handle :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WinBioCloseSession = Win32::API::More->new('winbio',
'int WinBioCloseSession(DWORD SessionHandle)');
# my $ret = $WinBioCloseSession->Call($SessionHandle);
# SessionHandle : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f WinBioOpenSession — 生体認証操作用のセッションを開きハンドルを取得する。