Win32 API 日本語リファレンス
ホーム › Devices.BiometricFramework › WinBioEnrollSelect

WinBioEnrollSelect

関数
登録処理中に使用するサブ要素を選択する。
DLLwinbio.dll呼出規約winapi対応OSWindows 10 以降

シグネチャ

// winbio.dll
#include <windows.h>

HRESULT WinBioEnrollSelect(
    DWORD SessionHandle,
    ULONGLONG SelectorValue
);

パラメーター

名前型方向説明
SessionHandleDWORDin

開いているバイオメトリックセッションを識別する WINBIO_SESSION_HANDLE 値です。同期セッションハンドルは WinBioOpenSession を呼び出して開きます。非同期セッションハンドルは WinBioAsyncOpenSession を呼び出して開きます。

顔認識での登録では、PoolType パラメーターに WINBIO_POOL_SYSTEM を設定して WinBioAsyncOpenSession を使用し、ハンドルを取得します。

SelectorValueULONGLONGin登録対象として選択する個人を識別する値です。

戻り値の型: HRESULT

公式ドキュメント

サンプルバッファーに複数の個人を表すデータが存在する場合に、登録する個人を指定します。Windows 10 ビルド 1607 以降では、この関数をモバイルイメージで使用できます。

戻り値

関数が成功した場合は S_OK を返します。失敗した場合は、エラーを示す HRESULT 値を返します。返される可能性のある値には、次の表に示すものが含まれます (ただしこれらに限定されません)。一般的なエラーコードの一覧については、Common HRESULT Values を参照してください。

戻り値 説明
E_HANDLE
セッションハンドルが無効です。
E_INVALIDARG
SelectorValue パラメーターに 0 を指定することはできません。
WINBIO_E_INCORRECT_SESSION_TYPE
セッションハンドルがバイオメトリックセッションに対応していません。

解説(Remarks)

顔認識での登録では、正しいセレクター値を次の 2 つのいずれかの方法で確認できます。

登録シーケンスを開始するために WinBioEnrollBegin を呼び出した後、WinBioEnrollSelect を呼び出してセレクター値を設定します。セレクター値は、以降のすべての WinBioEnrollCapture の呼び出しに適用されます。この選択設定は一時的なもので、WinBioEnrollCommit または WinBioEnrollDiscard を呼び出して登録シーケンスを終了すると、自動的にクリアされます。

指紋など、あいまいさの解消を必要としないバイオメトリック要素に対して WinBioEnrollSelect を呼び出した場合、関数の戻り値は成功を示しますが、セレクター値は無視されます。

この関数の呼び出しが必要なバイオメトリック要素に対して WinBioEnrollSelect を呼び出さなかった場合、以降の WinBioEnrollCapture の呼び出しは WINBIO_E_SELECTION_REQUIRED エラーで失敗します。

Windows 10 では、WinBioEnrollSelect の呼び出しが必要な要素は顔の特徴と虹彩です。

WinBioEnrollSelect は、同期セッションハンドルと非同期セッションハンドルのどちらを使用しても呼び出せます。Windows Biometric Framework API の他の関数の呼び出しと同様に、非同期セッションハンドルを指定して WinBioEnrollSelect を呼び出した場合、戻り値は関数のパラメーターが受け入れられたことのみを示します。操作自体の実際の成否は、WINBIO_ASYNC_RESULT 構造体で通知ルーチンに返されます。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// winbio.dll
#include <windows.h>

HRESULT WinBioEnrollSelect(
    DWORD SessionHandle,
    ULONGLONG SelectorValue
);
[DllImport("winbio.dll", ExactSpelling = true)]
static extern int WinBioEnrollSelect(
    uint SessionHandle,   // DWORD
    ulong SelectorValue   // ULONGLONG
);
<DllImport("winbio.dll", ExactSpelling:=True)>
Public Shared Function WinBioEnrollSelect(
    SessionHandle As UInteger,   ' DWORD
    SelectorValue As ULong   ' ULONGLONG
) As Integer
End Function
' SessionHandle : DWORD
' SelectorValue : ULONGLONG
Declare PtrSafe Function WinBioEnrollSelect Lib "winbio" ( _
    ByVal SessionHandle As Long, _
    ByVal SelectorValue As LongLong) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WinBioEnrollSelect = ctypes.windll.winbio.WinBioEnrollSelect
WinBioEnrollSelect.restype = ctypes.c_int
WinBioEnrollSelect.argtypes = [
    wintypes.DWORD,  # SessionHandle : DWORD
    ctypes.c_ulonglong,  # SelectorValue : ULONGLONG
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('winbio.dll')
WinBioEnrollSelect = Fiddle::Function.new(
  lib['WinBioEnrollSelect'],
  [
    -Fiddle::TYPE_INT,  # SessionHandle : DWORD
    -Fiddle::TYPE_LONG_LONG,  # SelectorValue : ULONGLONG
  ],
  Fiddle::TYPE_INT)
#[link(name = "winbio")]
extern "system" {
    fn WinBioEnrollSelect(
        SessionHandle: u32,  // DWORD
        SelectorValue: u64  // ULONGLONG
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("winbio.dll")]
public static extern int WinBioEnrollSelect(uint SessionHandle, ulong SelectorValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winbio_WinBioEnrollSelect' -Namespace Win32 -PassThru
# $api::WinBioEnrollSelect(SessionHandle, SelectorValue)
#uselib "winbio.dll"
#func global WinBioEnrollSelect "WinBioEnrollSelect" sptr, sptr
; WinBioEnrollSelect SessionHandle, SelectorValue   ; 戻り値は stat
; SessionHandle : DWORD -> "sptr"
; SelectorValue : ULONGLONG -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "winbio.dll"
#cfunc global WinBioEnrollSelect "WinBioEnrollSelect" int, int64
; res = WinBioEnrollSelect(SessionHandle, SelectorValue)
; SessionHandle : DWORD -> "int"
; SelectorValue : ULONGLONG -> "int64"
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
; HRESULT WinBioEnrollSelect(DWORD SessionHandle, ULONGLONG SelectorValue)
#uselib "winbio.dll"
#cfunc global WinBioEnrollSelect "WinBioEnrollSelect" int, int64
; res = WinBioEnrollSelect(SessionHandle, SelectorValue)
; SessionHandle : DWORD -> "int"
; SelectorValue : ULONGLONG -> "int64"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winbio = windows.NewLazySystemDLL("winbio.dll")
	procWinBioEnrollSelect = winbio.NewProc("WinBioEnrollSelect")
)

// SessionHandle (DWORD), SelectorValue (ULONGLONG)
r1, _, err := procWinBioEnrollSelect.Call(
	uintptr(SessionHandle),
	uintptr(SelectorValue),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WinBioEnrollSelect(
  SessionHandle: DWORD;   // DWORD
  SelectorValue: UInt64   // ULONGLONG
): Integer; stdcall;
  external 'winbio.dll' name 'WinBioEnrollSelect';
result := DllCall("winbio\WinBioEnrollSelect"
    , "UInt", SessionHandle   ; DWORD
    , "Int64", SelectorValue   ; ULONGLONG
    , "Int")   ; return: HRESULT
●WinBioEnrollSelect(SessionHandle, SelectorValue) = DLL("winbio.dll", "int WinBioEnrollSelect(dword, qword)")
# 呼び出し: WinBioEnrollSelect(SessionHandle, SelectorValue)
# SessionHandle : DWORD -> "dword"
# SelectorValue : ULONGLONG -> "qword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "winbio" fn WinBioEnrollSelect(
    SessionHandle: u32, // DWORD
    SelectorValue: u64 // ULONGLONG
) callconv(std.os.windows.WINAPI) i32;
proc WinBioEnrollSelect(
    SessionHandle: uint32,  # DWORD
    SelectorValue: uint64  # ULONGLONG
): int32 {.importc: "WinBioEnrollSelect", stdcall, dynlib: "winbio.dll".}
pragma(lib, "winbio");
extern(Windows)
int WinBioEnrollSelect(
    uint SessionHandle,   // DWORD
    ulong SelectorValue   // ULONGLONG
);
ccall((:WinBioEnrollSelect, "winbio.dll"), stdcall, Int32,
      (UInt32, UInt64),
      SessionHandle, SelectorValue)
# SessionHandle : DWORD -> UInt32
# SelectorValue : ULONGLONG -> UInt64
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WinBioEnrollSelect(
    uint32_t SessionHandle,
    uint64_t SelectorValue);
]]
local winbio = ffi.load("winbio")
-- winbio.WinBioEnrollSelect(SessionHandle, SelectorValue)
-- SessionHandle : DWORD
-- SelectorValue : ULONGLONG
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('winbio.dll');
const WinBioEnrollSelect = lib.func('__stdcall', 'WinBioEnrollSelect', 'int32_t', ['uint32_t', 'uint64_t']);
// WinBioEnrollSelect(SessionHandle, SelectorValue)
// SessionHandle : DWORD -> 'uint32_t'
// SelectorValue : ULONGLONG -> 'uint64_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("winbio.dll", {
  WinBioEnrollSelect: { parameters: ["u32", "u64"], result: "i32" },
});
// lib.symbols.WinBioEnrollSelect(SessionHandle, SelectorValue)
// SessionHandle : DWORD -> "u32"
// SelectorValue : ULONGLONG -> "u64"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WinBioEnrollSelect(
    uint32_t SessionHandle,
    uint64_t SelectorValue);
C, "winbio.dll");
// $ffi->WinBioEnrollSelect(SessionHandle, SelectorValue);
// SessionHandle : DWORD
// SelectorValue : ULONGLONG
// 構造体/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 WinBioEnrollSelect(
        int SessionHandle,   // DWORD
        long SelectorValue   // ULONGLONG
    );
}
@[Link("winbio")]
lib Libwinbio
  fun WinBioEnrollSelect = WinBioEnrollSelect(
    SessionHandle : UInt32,   # DWORD
    SelectorValue : UInt64   # ULONGLONG
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WinBioEnrollSelectNative = Int32 Function(Uint32, Uint64);
typedef WinBioEnrollSelectDart = int Function(int, int);
final WinBioEnrollSelect = DynamicLibrary.open('winbio.dll')
    .lookupFunction<WinBioEnrollSelectNative, WinBioEnrollSelectDart>('WinBioEnrollSelect');
// SessionHandle : DWORD -> Uint32
// SelectorValue : ULONGLONG -> Uint64
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WinBioEnrollSelect(
  SessionHandle: DWORD;   // DWORD
  SelectorValue: UInt64   // ULONGLONG
): Integer; stdcall;
  external 'winbio.dll' name 'WinBioEnrollSelect';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WinBioEnrollSelect"
  c_WinBioEnrollSelect :: Word32 -> Word64 -> IO Int32
-- SessionHandle : DWORD -> Word32
-- SelectorValue : ULONGLONG -> Word64
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let winbioenrollselect =
  foreign "WinBioEnrollSelect"
    (uint32_t @-> uint64_t @-> returning int32_t)
(* SessionHandle : DWORD -> uint32_t *)
(* SelectorValue : ULONGLONG -> uint64_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library winbio (t "winbio.dll"))
(cffi:use-foreign-library winbio)

(cffi:defcfun ("WinBioEnrollSelect" win-bio-enroll-select :convention :stdcall) :int32
  (session-handle :uint32)   ; DWORD
  (selector-value :uint64))   ; ULONGLONG
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WinBioEnrollSelect = Win32::API::More->new('winbio',
    'int WinBioEnrollSelect(DWORD SessionHandle, UINT64 SelectorValue)');
# my $ret = $WinBioEnrollSelect->Call($SessionHandle, $SelectorValue);
# SessionHandle : DWORD -> DWORD
# SelectorValue : ULONGLONG -> UINT64
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目