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

WinBioGetProperty

関数
生体認証の指定プロパティ値を取得する。
DLLwinbio.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

HRESULT WinBioGetProperty(
    DWORD SessionHandle,
    DWORD PropertyType,
    DWORD PropertyId,
    DWORD UnitId,   // optional
    WINBIO_IDENTITY* Identity,   // optional
    BYTE SubFactor,   // optional
    void** PropertyBuffer,
    UINT_PTR* PropertyBufferSize   // optional
);

パラメーター

名前型方向説明
SessionHandleDWORDinオープンされているバイオメトリック セッションを識別する WINBIO_SESSION_HANDLE 値です。同期セッション ハンドルは WinBioOpenSession を呼び出して開きます。非同期セッション ハンドルは WinBioAsyncOpenSession を呼び出して開きます。
PropertyTypeDWORDin

プロパティ情報の取得元を指定する WINBIO_PROPERTY_TYPE 値です。現時点では、WINBIO_PROPERTY_TYPE_UNIT または WINBIO_PROPERTY_TYPE_ACCOUNT のいずれかである必要があります。プロパティの種類の詳細については、WINBIO_PROPERTY_TYPE Constants を参照してください。

WINBIO_PROPERTY_TYPE_ACCOUNT 値は Windows 10 以降でサポートされます。

PropertyIdDWORDin

照会するプロパティを指定する WINBIO_PROPERTY_ID 値です。指定できる値は次のとおりです。

値 意味
WINBIO_PROPERTY_SAMPLE_HINT
登録テンプレートを完成させるために必要となる、良好なバイオメトリック サンプルの最大数の推定値です。プロパティ照会の結果は、PropertyBuffer パラメーターが指すバッファーに、そのヒントを格納した ULONG 値として返されます。
WINBIO_PROPERTY_EXTENDED_SENSOR_INFO
特定のバイオメトリック ユニットに接続されたセンサー コンポーネントの機能と属性に関する拡張情報が格納されます。プロパティ照会の結果は、PropertyBuffer パラメーターが指すバッファーに WINBIO_EXTENDED_SENSOR_INFO 構造体として返されます。 この値は Windows 10 以降でサポートされます。
WINBIO_PROPERTY_EXTENDED_ENGINE_INFO
特定のバイオメトリック ユニットに接続されたエンジン コンポーネントの機能と属性に関する拡張情報が格納されます。プロパティ照会の結果は、PropertyBuffer パラメーターが指すバッファーに WINBIO_EXTENDED_ENGINE_INFO 構造体として返されます。 この値は Windows 10 以降でサポートされます。
WINBIO_PROPERTY_EXTENDED_STORAGE_INFO
特定のバイオメトリック ユニットに接続されたストレージ コンポーネントの機能と属性に関する拡張情報が格納されます。プロパティ照会の結果は、PropertyBuffer パラメーターが指すバッファーに WINBIO_EXTENDED_STORAGE_INFO 構造体として返されます。 この値は Windows 10 以降でサポートされます。
WINBIO_PROPERTY_EXTENDED_ENROLLMENT_STATUS
特定のバイオメトリック ユニットで進行中の登録の状態に関する拡張情報が格納されます。プロパティ照会の結果は、PropertyBuffer パラメーターが指すバッファーに WINBIO_EXTENDED_ENROLLMENT_STATUS 構造体として返されます。そのバイオメトリック ユニットで登録が進行中でない場合、返される構造体の TemplateStatus メンバーの値は WINBIO_E_INVALID_OPERATION になります。 この値は Windows 10 以降でサポートされます。
WINBIO_PROPERTY_ANTI_SPOOF_POLICY
特定のユーザー アカウントに対するなりすまし防止ポリシーの値が格納されます。プロパティ操作の結果は、PropertyBuffer パラメーターが指すバッファーに WINBIO_ANTI_SPOOF_POLICY 構造体として返されます。 この値は Windows 10 以降でサポートされます。

これらのプロパティの詳細については、WINBIO_PROPERTY Constants を参照してください。

UnitIdDWORDinoptional

バイオメトリック ユニットを識別する WINBIO_UNIT_ID 値です。ユニット識別子は、WinBioEnumBiometricUnits 関数または WinBioLocateSensor 関数を呼び出して取得できます。

PropertyId パラメーターの値として WINBIO_PROPERTY_ANTI_SPOOF_POLICY を指定する場合は、UnitId パラメーターに 0 を指定します。PropertyId パラメーターにそれ以外のプロパティを指定する場合、UnitId パラメーターに 0 を指定することはできません。

IdentityWINBIO_IDENTITY*inoptional

PropertyId パラメーターの値として WINBIO_PROPERTY_ANTI_SPOOF_POLICY を指定する場合に、なりすまし防止ポリシーを取得する対象アカウントの SID を指定する WINBIO_IDENTITY 構造体です。

PropertyId パラメーターにそれ以外の値を指定する場合、Identity パラメーターは NULL でなければなりません。

SubFactorBYTEinoptional予約済みです。WINBIO_SUBTYPE_NO_INFORMATION でなければなりません。
PropertyBuffervoid**outプロパティ値を受け取るバッファーへのポインターのアドレスです。プロパティごとのこのバッファーの内容については、PropertyId パラメーターにおける各プロパティ値の説明を参照してください。
PropertyBufferSizeUINT_PTR*outoptionalPropertyBuffer パラメーターが指すバッファーのサイズ (バイト単位) を受け取る変数へのポインターです。

戻り値の型: HRESULT

公式ドキュメント

セッション、ユニット、またはテンプレートのプロパティを取得します。Windows 10 ビルド 1607 以降、この関数はモバイル イメージでも使用できます。

戻り値

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

戻り値 説明
E_HANDLE
SessionHandle パラメーターで指定されたセッション ハンドルが無効です。
E_POINTER
Identity、PropertyBuffer、PropertyBufferSize の各引数を NULL にすることはできません。
E_INVALIDARG
UnitId、Identity、または SubFactor の引数が正しくありません。
WINBIO_E_INVALID_PROPERTY_TYPE
PropertyType 引数の値が正しくありません。
WINBIO_E_INVALID_PROPERTY_ID
PropertyId 引数の値が正しくありません。
WINBIO_E_LOCK_VIOLATION
呼び出し元が、ロックされた領域内にあるプロパティを照会しようとしました。
WINBIO_E_UNSUPPORTED_PROPERTY
照会対象のオブジェクトが、指定されたプロパティをサポートしていません。
WINBIO_E_ENROLLMENT_IN_PROGRESS
指定されたバイオメトリック ユニットが現在、登録トランザクションで使用されているため、操作を完了できませんでした (システム プールのみ)。

解説(Remarks)

WinBioGetProperty を同期的に使用するには、WinBioOpenSession の呼び出しで作成したセッション ハンドルを指定してこの関数を呼び出します。この関数は、操作が完了するかエラーが発生するまでブロックします。WinBioGetProperty を同期的に使用する場合にメモリ リークを防ぐには、バッファーに格納されたデータの使用を終えた時点で WinBioFree を呼び出し、PropertyBuffer パラメーターが指すメモリを解放する必要があります。

WinBioGetProperty を非同期的に使用するには、WinBioAsyncOpenSession の呼び出しで作成したセッション ハンドルを指定してこの関数を呼び出します。フレームワークは WINBIO_ASYNC_RESULT 構造体を割り当て、それを使用して操作の成否に関する情報を返します。操作が成功した場合、フレームワークは入れ子になった GetProperty 構造体に情報を返します。WINBIO_ASYNC_RESULT 構造体は、WinBioAsyncOpenSession 関数の NotificationMethod パラメーターに設定した値に応じて、アプリケーションのコールバックまたはアプリケーションのメッセージ キューに返されます。

WinBioGetProperty を非同期的に使用する場合にメモリ リークを防ぐには、使用を終えた時点で WinBioFree を呼び出して WINBIO_ASYNC_RESULT 構造体を解放する必要があります。WINBIO_ASYNC_RESULT 構造体とプロパティ バッファーは 1 つのメモリ ブロックを占有するため、アプリケーションは WINBIO_ASYNC_RESULT 構造体のアドレスを WinBioFree に渡すだけで済みます。この方法で WinBioFree を呼び出すと、WinBioFree は 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 WinBioGetProperty(
    DWORD SessionHandle,
    DWORD PropertyType,
    DWORD PropertyId,
    DWORD UnitId,   // optional
    WINBIO_IDENTITY* Identity,   // optional
    BYTE SubFactor,   // optional
    void** PropertyBuffer,
    UINT_PTR* PropertyBufferSize   // optional
);
[DllImport("winbio.dll", ExactSpelling = true)]
static extern int WinBioGetProperty(
    uint SessionHandle,   // DWORD
    uint PropertyType,   // DWORD
    uint PropertyId,   // DWORD
    uint UnitId,   // DWORD optional
    IntPtr Identity,   // WINBIO_IDENTITY* optional
    byte SubFactor,   // BYTE optional
    IntPtr PropertyBuffer,   // void** out
    IntPtr PropertyBufferSize   // UINT_PTR* optional, out
);
<DllImport("winbio.dll", ExactSpelling:=True)>
Public Shared Function WinBioGetProperty(
    SessionHandle As UInteger,   ' DWORD
    PropertyType As UInteger,   ' DWORD
    PropertyId As UInteger,   ' DWORD
    UnitId As UInteger,   ' DWORD optional
    Identity As IntPtr,   ' WINBIO_IDENTITY* optional
    SubFactor As Byte,   ' BYTE optional
    PropertyBuffer As IntPtr,   ' void** out
    PropertyBufferSize As IntPtr   ' UINT_PTR* optional, out
) As Integer
End Function
' SessionHandle : DWORD
' PropertyType : DWORD
' PropertyId : DWORD
' UnitId : DWORD optional
' Identity : WINBIO_IDENTITY* optional
' SubFactor : BYTE optional
' PropertyBuffer : void** out
' PropertyBufferSize : UINT_PTR* optional, out
Declare PtrSafe Function WinBioGetProperty Lib "winbio" ( _
    ByVal SessionHandle As Long, _
    ByVal PropertyType As Long, _
    ByVal PropertyId As Long, _
    ByVal UnitId As Long, _
    ByVal Identity As LongPtr, _
    ByVal SubFactor As Byte, _
    ByVal PropertyBuffer As LongPtr, _
    ByVal PropertyBufferSize As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WinBioGetProperty = ctypes.windll.winbio.WinBioGetProperty
WinBioGetProperty.restype = ctypes.c_int
WinBioGetProperty.argtypes = [
    wintypes.DWORD,  # SessionHandle : DWORD
    wintypes.DWORD,  # PropertyType : DWORD
    wintypes.DWORD,  # PropertyId : DWORD
    wintypes.DWORD,  # UnitId : DWORD optional
    ctypes.c_void_p,  # Identity : WINBIO_IDENTITY* optional
    ctypes.c_ubyte,  # SubFactor : BYTE optional
    ctypes.c_void_p,  # PropertyBuffer : void** out
    ctypes.POINTER(ctypes.c_size_t),  # PropertyBufferSize : UINT_PTR* optional, out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	winbio = windows.NewLazySystemDLL("winbio.dll")
	procWinBioGetProperty = winbio.NewProc("WinBioGetProperty")
)

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

extern "winbio" fn WinBioGetProperty(
    SessionHandle: u32, // DWORD
    PropertyType: u32, // DWORD
    PropertyId: u32, // DWORD
    UnitId: u32, // DWORD optional
    Identity: [*c]WINBIO_IDENTITY, // WINBIO_IDENTITY* optional
    SubFactor: u8, // BYTE optional
    PropertyBuffer: ?*anyopaque, // void** out
    PropertyBufferSize: [*c]usize // UINT_PTR* optional, out
) callconv(std.os.windows.WINAPI) i32;
proc WinBioGetProperty(
    SessionHandle: uint32,  # DWORD
    PropertyType: uint32,  # DWORD
    PropertyId: uint32,  # DWORD
    UnitId: uint32,  # DWORD optional
    Identity: ptr WINBIO_IDENTITY,  # WINBIO_IDENTITY* optional
    SubFactor: uint8,  # BYTE optional
    PropertyBuffer: pointer,  # void** out
    PropertyBufferSize: ptr uint  # UINT_PTR* optional, out
): int32 {.importc: "WinBioGetProperty", stdcall, dynlib: "winbio.dll".}
pragma(lib, "winbio");
extern(Windows)
int WinBioGetProperty(
    uint SessionHandle,   // DWORD
    uint PropertyType,   // DWORD
    uint PropertyId,   // DWORD
    uint UnitId,   // DWORD optional
    WINBIO_IDENTITY* Identity,   // WINBIO_IDENTITY* optional
    ubyte SubFactor,   // BYTE optional
    void** PropertyBuffer,   // void** out
    size_t* PropertyBufferSize   // UINT_PTR* optional, out
);
ccall((:WinBioGetProperty, "winbio.dll"), stdcall, Int32,
      (UInt32, UInt32, UInt32, UInt32, Ptr{WINBIO_IDENTITY}, UInt8, Ptr{Cvoid}, Ptr{Csize_t}),
      SessionHandle, PropertyType, PropertyId, UnitId, Identity, SubFactor, PropertyBuffer, PropertyBufferSize)
# SessionHandle : DWORD -> UInt32
# PropertyType : DWORD -> UInt32
# PropertyId : DWORD -> UInt32
# UnitId : DWORD optional -> UInt32
# Identity : WINBIO_IDENTITY* optional -> Ptr{WINBIO_IDENTITY}
# SubFactor : BYTE optional -> UInt8
# PropertyBuffer : void** out -> Ptr{Cvoid}
# PropertyBufferSize : UINT_PTR* optional, out -> Ptr{Csize_t}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WinBioGetProperty(
    uint32_t SessionHandle,
    uint32_t PropertyType,
    uint32_t PropertyId,
    uint32_t UnitId,
    void* Identity,
    uint8_t SubFactor,
    void** PropertyBuffer,
    uintptr_t* PropertyBufferSize);
]]
local winbio = ffi.load("winbio")
-- winbio.WinBioGetProperty(SessionHandle, PropertyType, PropertyId, UnitId, Identity, SubFactor, PropertyBuffer, PropertyBufferSize)
-- SessionHandle : DWORD
-- PropertyType : DWORD
-- PropertyId : DWORD
-- UnitId : DWORD optional
-- Identity : WINBIO_IDENTITY* optional
-- SubFactor : BYTE optional
-- PropertyBuffer : void** out
-- PropertyBufferSize : UINT_PTR* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('winbio.dll');
const WinBioGetProperty = lib.func('__stdcall', 'WinBioGetProperty', 'int32_t', ['uint32_t', 'uint32_t', 'uint32_t', 'uint32_t', 'void *', 'uint8_t', 'void *', 'uintptr_t *']);
// WinBioGetProperty(SessionHandle, PropertyType, PropertyId, UnitId, Identity, SubFactor, PropertyBuffer, PropertyBufferSize)
// SessionHandle : DWORD -> 'uint32_t'
// PropertyType : DWORD -> 'uint32_t'
// PropertyId : DWORD -> 'uint32_t'
// UnitId : DWORD optional -> 'uint32_t'
// Identity : WINBIO_IDENTITY* optional -> 'void *'
// SubFactor : BYTE optional -> 'uint8_t'
// PropertyBuffer : void** out -> 'void *'
// PropertyBufferSize : UINT_PTR* optional, out -> 'uintptr_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("winbio.dll", {
  WinBioGetProperty: { parameters: ["u32", "u32", "u32", "u32", "pointer", "u8", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WinBioGetProperty(SessionHandle, PropertyType, PropertyId, UnitId, Identity, SubFactor, PropertyBuffer, PropertyBufferSize)
// SessionHandle : DWORD -> "u32"
// PropertyType : DWORD -> "u32"
// PropertyId : DWORD -> "u32"
// UnitId : DWORD optional -> "u32"
// Identity : WINBIO_IDENTITY* optional -> "pointer"
// SubFactor : BYTE optional -> "u8"
// PropertyBuffer : void** out -> "pointer"
// PropertyBufferSize : UINT_PTR* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WinBioGetProperty(
    uint32_t SessionHandle,
    uint32_t PropertyType,
    uint32_t PropertyId,
    uint32_t UnitId,
    void* Identity,
    uint8_t SubFactor,
    void** PropertyBuffer,
    size_t* PropertyBufferSize);
C, "winbio.dll");
// $ffi->WinBioGetProperty(SessionHandle, PropertyType, PropertyId, UnitId, Identity, SubFactor, PropertyBuffer, PropertyBufferSize);
// SessionHandle : DWORD
// PropertyType : DWORD
// PropertyId : DWORD
// UnitId : DWORD optional
// Identity : WINBIO_IDENTITY* optional
// SubFactor : BYTE optional
// PropertyBuffer : void** out
// PropertyBufferSize : UINT_PTR* 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 WinBioGetProperty(
        int SessionHandle,   // DWORD
        int PropertyType,   // DWORD
        int PropertyId,   // DWORD
        int UnitId,   // DWORD optional
        Pointer Identity,   // WINBIO_IDENTITY* optional
        byte SubFactor,   // BYTE optional
        Pointer PropertyBuffer,   // void** out
        LongByReference PropertyBufferSize   // UINT_PTR* optional, out
    );
}
@[Link("winbio")]
lib Libwinbio
  fun WinBioGetProperty = WinBioGetProperty(
    SessionHandle : UInt32,   # DWORD
    PropertyType : UInt32,   # DWORD
    PropertyId : UInt32,   # DWORD
    UnitId : UInt32,   # DWORD optional
    Identity : WINBIO_IDENTITY*,   # WINBIO_IDENTITY* optional
    SubFactor : UInt8,   # BYTE optional
    PropertyBuffer : Void**,   # void** out
    PropertyBufferSize : LibC::SizeT*   # UINT_PTR* 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 WinBioGetPropertyNative = Int32 Function(Uint32, Uint32, Uint32, Uint32, Pointer<Void>, Uint8, Pointer<Void>, Pointer<UintPtr>);
typedef WinBioGetPropertyDart = int Function(int, int, int, int, Pointer<Void>, int, Pointer<Void>, Pointer<UintPtr>);
final WinBioGetProperty = DynamicLibrary.open('winbio.dll')
    .lookupFunction<WinBioGetPropertyNative, WinBioGetPropertyDart>('WinBioGetProperty');
// SessionHandle : DWORD -> Uint32
// PropertyType : DWORD -> Uint32
// PropertyId : DWORD -> Uint32
// UnitId : DWORD optional -> Uint32
// Identity : WINBIO_IDENTITY* optional -> Pointer<Void>
// SubFactor : BYTE optional -> Uint8
// PropertyBuffer : void** out -> Pointer<Void>
// PropertyBufferSize : UINT_PTR* optional, out -> Pointer<UintPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WinBioGetProperty(
  SessionHandle: DWORD;   // DWORD
  PropertyType: DWORD;   // DWORD
  PropertyId: DWORD;   // DWORD
  UnitId: DWORD;   // DWORD optional
  Identity: Pointer;   // WINBIO_IDENTITY* optional
  SubFactor: Byte;   // BYTE optional
  PropertyBuffer: Pointer;   // void** out
  PropertyBufferSize: Pointer   // UINT_PTR* optional, out
): Integer; stdcall;
  external 'winbio.dll' name 'WinBioGetProperty';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WinBioGetProperty"
  c_WinBioGetProperty :: Word32 -> Word32 -> Word32 -> Word32 -> Ptr () -> Word8 -> Ptr () -> Ptr CUIntPtr -> IO Int32
-- SessionHandle : DWORD -> Word32
-- PropertyType : DWORD -> Word32
-- PropertyId : DWORD -> Word32
-- UnitId : DWORD optional -> Word32
-- Identity : WINBIO_IDENTITY* optional -> Ptr ()
-- SubFactor : BYTE optional -> Word8
-- PropertyBuffer : void** out -> Ptr ()
-- PropertyBufferSize : UINT_PTR* optional, out -> Ptr CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let winbiogetproperty =
  foreign "WinBioGetProperty"
    (uint32_t @-> uint32_t @-> uint32_t @-> uint32_t @-> (ptr void) @-> uint8_t @-> (ptr void) @-> (ptr size_t) @-> returning int32_t)
(* SessionHandle : DWORD -> uint32_t *)
(* PropertyType : DWORD -> uint32_t *)
(* PropertyId : DWORD -> uint32_t *)
(* UnitId : DWORD optional -> uint32_t *)
(* Identity : WINBIO_IDENTITY* optional -> (ptr void) *)
(* SubFactor : BYTE optional -> uint8_t *)
(* PropertyBuffer : void** out -> (ptr void) *)
(* PropertyBufferSize : UINT_PTR* optional, 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 ("WinBioGetProperty" win-bio-get-property :convention :stdcall) :int32
  (session-handle :uint32)   ; DWORD
  (property-type :uint32)   ; DWORD
  (property-id :uint32)   ; DWORD
  (unit-id :uint32)   ; DWORD optional
  (identity :pointer)   ; WINBIO_IDENTITY* optional
  (sub-factor :uint8)   ; BYTE optional
  (property-buffer :pointer)   ; void** out
  (property-buffer-size :pointer))   ; UINT_PTR* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WinBioGetProperty = Win32::API::More->new('winbio',
    'int WinBioGetProperty(DWORD SessionHandle, DWORD PropertyType, DWORD PropertyId, DWORD UnitId, LPVOID Identity, BYTE SubFactor, LPVOID PropertyBuffer, LPVOID PropertyBufferSize)');
# my $ret = $WinBioGetProperty->Call($SessionHandle, $PropertyType, $PropertyId, $UnitId, $Identity, $SubFactor, $PropertyBuffer, $PropertyBufferSize);
# SessionHandle : DWORD -> DWORD
# PropertyType : DWORD -> DWORD
# PropertyId : DWORD -> DWORD
# UnitId : DWORD optional -> DWORD
# Identity : WINBIO_IDENTITY* optional -> LPVOID
# SubFactor : BYTE optional -> BYTE
# PropertyBuffer : void** out -> LPVOID
# PropertyBufferSize : UINT_PTR* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

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