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

WinBioEnumServiceProviders

関数
指定した生体認証要素のサービスプロバイダ一覧を列挙する。
DLLwinbio.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

HRESULT WinBioEnumServiceProviders(
    DWORD Factor,
    WINBIO_BSP_SCHEMA** BspSchemaArray,
    UINT_PTR* BspCount
);

パラメーター

名前型方向説明
FactorDWORDin列挙するバイオメトリックユニットの種類を指定する WINBIO_BIOMETRIC_TYPE フラグのビットマスクです。現在は WINBIO_TYPE_FINGERPRINT のみがサポートされています。
BspSchemaArrayWINBIO_BSP_SCHEMA**out利用可能な各サービスプロバイダーに関する情報を格納した WINBIO_BSP_SCHEMA 構造体の配列へのポインターを受け取る変数のアドレスです。関数が成功しなかった場合、このポインターには NULL が設定されます。関数が成功した場合は、配列のために内部で割り当てられたメモリを解放するために、このポインターを WinBioFree に渡す必要があります。
BspCountUINT_PTR*outBspSchemaArray パラメーターが指す構造体の数を格納する値へのポインターです。

戻り値の型: HRESULT

公式ドキュメント

インストールされているバイオメトリックサービスプロバイダーに関する情報を取得します。Windows 10 ビルド 1607 以降、この関数はモバイルイメージで使用できます。

戻り値

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

戻り値 説明
E_INVALIDARG
Factor パラメーターに含まれるビットマスクに、1 つ以上の無効な種類のビットが含まれています。
E_OUTOFMEMORY
要求を完了するためのメモリが不足していました。
E_POINTER
BspSchemaArray パラメーターおよび BspCount パラメーターに NULL を指定することはできません。

解説(Remarks)

現在、Factor パラメーターでは WINBIO_TYPE_FINGERPRINT のみがサポートされています。

BspSchemaArray パラメーターに返された構造体の使用が終わったら、配列のために内部で割り当てられたメモリを解放するために WinBioFree を呼び出す必要があります。

Factor ビットマスク内のすべての要素ビットがサポートされていないバイオメトリックの種類を指している場合、関数は S_OK を返しますが、BspSchemaArray パラメーターが指す値は NULL になり、BspCount パラメーターにはゼロが格納されます。サポートされていないバイオメトリック要素について問い合わせてもエラーにはなりませんが、クエリの結果は空のセットになります。

例

次のコード例では、WinBioEnumServiceProviders を呼び出して、インストールされている サービスプロバイダーを列挙します。この例には、プロバイダー ID を表示する DisplayGuid 関数も含まれています。Winbio.lib 静的ライブラリにリンクし、次のヘッダーファイルをインクルードしてください。

HRESULT EnumSvcProviders( )
{
    // 変数を宣言します。
    HRESULT hr = S_OK;
    PWINBIO_BSP_SCHEMA bspSchemaArray = NULL;
    SIZE_T bspCount = 0;
    SIZE_T index = 0;

    // サービスプロバイダーを列挙します。
    hr = WinBioEnumServiceProviders( 
            WINBIO_TYPE_FINGERPRINT,    // 列挙するプロバイダー
            &bspSchemaArray,            // プロバイダースキーマの配列
            &bspCount );                // 返されたスキーマの数
    if (FAILED(hr))
    {
        wprintf_s(L"\n WinBioEnumServiceProviders failed. hr = 0x%x\n", hr);
        goto e_Exit;
    }

    // スキーマ情報を表示します。
    wprintf_s(L"\nService providers: \n");
    for (index = 0; index < bspCount; ++index)
    {
        wprintf_s(L"\n[%d]: \tBiometric factor: 0x%08x\n", 
                 index, 
                 bspSchemaArray[index].BiometricFactor );
        
        wprintf_s(L"\tBspId: ");
        DisplayGuid(&bspSchemaArray[index].BspId);
        wprintf_s(L"\n");

        wprintf_s(L"\tDescription: %ws\n", 
                 bspSchemaArray[index].Description);
        wprintf_s(L"\tVendor: %ws\n", 
                 bspSchemaArray[index].Vendor );
        wprintf_s(L"\tVersion: %d.%d\n", 
                 bspSchemaArray[index].Version.MajorVersion, 
                 bspSchemaArray[index].Version.MinorVersion);

        wprintf_s(L"\n");
    } 

e_Exit:
    if (bspSchemaArray != NULL)
    {
        WinBioFree(bspSchemaArray);
        bspSchemaArray = NULL;
    }

    wprintf_s(L"\nPress any key to exit...");
    _getch();

    return hr;
}

//------------------------------------------------------------------------
// 次の関数は、コンソールウィンドウに GUID を表示します。
//
VOID DisplayGuid( __in PWINBIO_UUID Guid )
{
    wprintf_s(
        L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
        Guid->Data1,
        Guid->Data2,
        Guid->Data3,
        Guid->Data4[0],
        Guid->Data4[1],
        Guid->Data4[2],
        Guid->Data4[3],
        Guid->Data4[4],
        Guid->Data4[5],
        Guid->Data4[6],
        Guid->Data4[7]
        );
}

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

各言語での呼び出し定義

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

HRESULT WinBioEnumServiceProviders(
    DWORD Factor,
    WINBIO_BSP_SCHEMA** BspSchemaArray,
    UINT_PTR* BspCount
);
[DllImport("winbio.dll", ExactSpelling = true)]
static extern int WinBioEnumServiceProviders(
    uint Factor,   // DWORD
    IntPtr BspSchemaArray,   // WINBIO_BSP_SCHEMA** out
    out UIntPtr BspCount   // UINT_PTR* out
);
<DllImport("winbio.dll", ExactSpelling:=True)>
Public Shared Function WinBioEnumServiceProviders(
    Factor As UInteger,   ' DWORD
    BspSchemaArray As IntPtr,   ' WINBIO_BSP_SCHEMA** out
    <Out> ByRef BspCount As UIntPtr   ' UINT_PTR* out
) As Integer
End Function
' Factor : DWORD
' BspSchemaArray : WINBIO_BSP_SCHEMA** out
' BspCount : UINT_PTR* out
Declare PtrSafe Function WinBioEnumServiceProviders Lib "winbio" ( _
    ByVal Factor As Long, _
    ByVal BspSchemaArray As LongPtr, _
    ByRef BspCount As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WinBioEnumServiceProviders = ctypes.windll.winbio.WinBioEnumServiceProviders
WinBioEnumServiceProviders.restype = ctypes.c_int
WinBioEnumServiceProviders.argtypes = [
    wintypes.DWORD,  # Factor : DWORD
    ctypes.c_void_p,  # BspSchemaArray : WINBIO_BSP_SCHEMA** out
    ctypes.POINTER(ctypes.c_size_t),  # BspCount : UINT_PTR* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('winbio.dll')
WinBioEnumServiceProviders = Fiddle::Function.new(
  lib['WinBioEnumServiceProviders'],
  [
    -Fiddle::TYPE_INT,  # Factor : DWORD
    Fiddle::TYPE_VOIDP,  # BspSchemaArray : WINBIO_BSP_SCHEMA** out
    Fiddle::TYPE_VOIDP,  # BspCount : UINT_PTR* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "winbio")]
extern "system" {
    fn WinBioEnumServiceProviders(
        Factor: u32,  // DWORD
        BspSchemaArray: *mut *mut WINBIO_BSP_SCHEMA,  // WINBIO_BSP_SCHEMA** out
        BspCount: *mut usize  // UINT_PTR* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("winbio.dll")]
public static extern int WinBioEnumServiceProviders(uint Factor, IntPtr BspSchemaArray, out UIntPtr BspCount);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winbio_WinBioEnumServiceProviders' -Namespace Win32 -PassThru
# $api::WinBioEnumServiceProviders(Factor, BspSchemaArray, BspCount)
#uselib "winbio.dll"
#func global WinBioEnumServiceProviders "WinBioEnumServiceProviders" sptr, sptr, sptr
; WinBioEnumServiceProviders Factor, varptr(BspSchemaArray), varptr(BspCount)   ; 戻り値は stat
; Factor : DWORD -> "sptr"
; BspSchemaArray : WINBIO_BSP_SCHEMA** out -> "sptr"
; BspCount : UINT_PTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "winbio.dll"
#cfunc global WinBioEnumServiceProviders "WinBioEnumServiceProviders" int, var, var
; res = WinBioEnumServiceProviders(Factor, BspSchemaArray, BspCount)
; Factor : DWORD -> "int"
; BspSchemaArray : WINBIO_BSP_SCHEMA** out -> "var"
; BspCount : UINT_PTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WinBioEnumServiceProviders(DWORD Factor, WINBIO_BSP_SCHEMA** BspSchemaArray, UINT_PTR* BspCount)
#uselib "winbio.dll"
#cfunc global WinBioEnumServiceProviders "WinBioEnumServiceProviders" int, var, var
; res = WinBioEnumServiceProviders(Factor, BspSchemaArray, BspCount)
; Factor : DWORD -> "int"
; BspSchemaArray : WINBIO_BSP_SCHEMA** out -> "var"
; BspCount : UINT_PTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winbio = windows.NewLazySystemDLL("winbio.dll")
	procWinBioEnumServiceProviders = winbio.NewProc("WinBioEnumServiceProviders")
)

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

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

typedef WinBioEnumServiceProvidersNative = Int32 Function(Uint32, Pointer<Void>, Pointer<UintPtr>);
typedef WinBioEnumServiceProvidersDart = int Function(int, Pointer<Void>, Pointer<UintPtr>);
final WinBioEnumServiceProviders = DynamicLibrary.open('winbio.dll')
    .lookupFunction<WinBioEnumServiceProvidersNative, WinBioEnumServiceProvidersDart>('WinBioEnumServiceProviders');
// Factor : DWORD -> Uint32
// BspSchemaArray : WINBIO_BSP_SCHEMA** out -> Pointer<Void>
// BspCount : UINT_PTR* out -> Pointer<UintPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WinBioEnumServiceProviders(
  Factor: DWORD;   // DWORD
  BspSchemaArray: Pointer;   // WINBIO_BSP_SCHEMA** out
  BspCount: Pointer   // UINT_PTR* out
): Integer; stdcall;
  external 'winbio.dll' name 'WinBioEnumServiceProviders';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WinBioEnumServiceProviders"
  c_WinBioEnumServiceProviders :: Word32 -> Ptr () -> Ptr CUIntPtr -> IO Int32
-- Factor : DWORD -> Word32
-- BspSchemaArray : WINBIO_BSP_SCHEMA** out -> Ptr ()
-- BspCount : UINT_PTR* out -> Ptr CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let winbioenumserviceproviders =
  foreign "WinBioEnumServiceProviders"
    (uint32_t @-> (ptr void) @-> (ptr size_t) @-> returning int32_t)
(* Factor : DWORD -> uint32_t *)
(* BspSchemaArray : WINBIO_BSP_SCHEMA** out -> (ptr void) *)
(* BspCount : UINT_PTR* out -> (ptr size_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library winbio (t "winbio.dll"))
(cffi:use-foreign-library winbio)

(cffi:defcfun ("WinBioEnumServiceProviders" win-bio-enum-service-providers :convention :stdcall) :int32
  (factor :uint32)   ; DWORD
  (bsp-schema-array :pointer)   ; WINBIO_BSP_SCHEMA** out
  (bsp-count :pointer))   ; UINT_PTR* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WinBioEnumServiceProviders = Win32::API::More->new('winbio',
    'int WinBioEnumServiceProviders(DWORD Factor, LPVOID BspSchemaArray, LPVOID BspCount)');
# my $ret = $WinBioEnumServiceProviders->Call($Factor, $BspSchemaArray, $BspCount);
# Factor : DWORD -> DWORD
# BspSchemaArray : WINBIO_BSP_SCHEMA** out -> LPVOID
# BspCount : UINT_PTR* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型