ホーム › Devices.BiometricFramework › WinBioOpenSession
WinBioOpenSession
関数生体認証操作用のセッションを開きハンドルを取得する。
シグネチャ
// winbio.dll
#include <windows.h>
HRESULT WinBioOpenSession(
DWORD Factor,
WINBIO_POOL PoolType,
DWORD Flags,
DWORD* UnitArray, // optional
UINT_PTR UnitCount, // optional
GUID* DatabaseId, // optional
DWORD* SessionHandle
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Factor | DWORD | in | セッションで扱う生体認証ファクターを表すフラグ。WINBIO_TYPE値の組み合わせ。 |
| PoolType | WINBIO_POOL | in | 使用するバイオメトリックユニットプールの種類(システム/プライベート)を指定。 |
| Flags | DWORD | in | セッションの動作を制御するフラグ。WINBIO_FLAG_RAW/DEFAULT等。 |
| UnitArray | DWORD* | inoptional | プライベートプール使用時に対象とするユニットIDの配列。システムプールではNULL可。 |
| UnitCount | UINT_PTR | inoptional | UnitArrayの要素数。システムプールでは0。 |
| DatabaseId | GUID* | inoptional | プライベートプール使用時のデータベースGUIDへのポインタ。システムプールではNULL可。 |
| SessionHandle | DWORD* | out | 開いたセッションのハンドルを受け取る出力ポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// winbio.dll
#include <windows.h>
HRESULT WinBioOpenSession(
DWORD Factor,
WINBIO_POOL PoolType,
DWORD Flags,
DWORD* UnitArray, // optional
UINT_PTR UnitCount, // optional
GUID* DatabaseId, // optional
DWORD* SessionHandle
);[DllImport("winbio.dll", ExactSpelling = true)]
static extern int WinBioOpenSession(
uint Factor, // DWORD
uint PoolType, // WINBIO_POOL
uint Flags, // DWORD
IntPtr UnitArray, // DWORD* optional
UIntPtr UnitCount, // UINT_PTR optional
IntPtr DatabaseId, // GUID* optional
out uint SessionHandle // DWORD* out
);<DllImport("winbio.dll", ExactSpelling:=True)>
Public Shared Function WinBioOpenSession(
Factor As UInteger, ' DWORD
PoolType As UInteger, ' WINBIO_POOL
Flags As UInteger, ' DWORD
UnitArray As IntPtr, ' DWORD* optional
UnitCount As UIntPtr, ' UINT_PTR optional
DatabaseId As IntPtr, ' GUID* optional
<Out> ByRef SessionHandle As UInteger ' DWORD* out
) As Integer
End Function' Factor : DWORD
' PoolType : WINBIO_POOL
' Flags : DWORD
' UnitArray : DWORD* optional
' UnitCount : UINT_PTR optional
' DatabaseId : GUID* optional
' SessionHandle : DWORD* out
Declare PtrSafe Function WinBioOpenSession Lib "winbio" ( _
ByVal Factor As Long, _
ByVal PoolType As Long, _
ByVal Flags As Long, _
ByVal UnitArray As LongPtr, _
ByVal UnitCount As LongPtr, _
ByVal DatabaseId As LongPtr, _
ByRef SessionHandle As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WinBioOpenSession = ctypes.windll.winbio.WinBioOpenSession
WinBioOpenSession.restype = ctypes.c_int
WinBioOpenSession.argtypes = [
wintypes.DWORD, # Factor : DWORD
wintypes.DWORD, # PoolType : WINBIO_POOL
wintypes.DWORD, # Flags : DWORD
ctypes.POINTER(wintypes.DWORD), # UnitArray : DWORD* optional
ctypes.c_size_t, # UnitCount : UINT_PTR optional
ctypes.c_void_p, # DatabaseId : GUID* optional
ctypes.POINTER(wintypes.DWORD), # SessionHandle : DWORD* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('winbio.dll')
WinBioOpenSession = Fiddle::Function.new(
lib['WinBioOpenSession'],
[
-Fiddle::TYPE_INT, # Factor : DWORD
-Fiddle::TYPE_INT, # PoolType : WINBIO_POOL
-Fiddle::TYPE_INT, # Flags : DWORD
Fiddle::TYPE_VOIDP, # UnitArray : DWORD* optional
Fiddle::TYPE_UINTPTR_T, # UnitCount : UINT_PTR optional
Fiddle::TYPE_VOIDP, # DatabaseId : GUID* optional
Fiddle::TYPE_VOIDP, # SessionHandle : DWORD* out
],
Fiddle::TYPE_INT)#[link(name = "winbio")]
extern "system" {
fn WinBioOpenSession(
Factor: u32, // DWORD
PoolType: u32, // WINBIO_POOL
Flags: u32, // DWORD
UnitArray: *mut u32, // DWORD* optional
UnitCount: usize, // UINT_PTR optional
DatabaseId: *mut GUID, // GUID* optional
SessionHandle: *mut u32 // DWORD* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("winbio.dll")]
public static extern int WinBioOpenSession(uint Factor, uint PoolType, uint Flags, IntPtr UnitArray, UIntPtr UnitCount, IntPtr DatabaseId, out uint SessionHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winbio_WinBioOpenSession' -Namespace Win32 -PassThru
# $api::WinBioOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, SessionHandle)#uselib "winbio.dll"
#func global WinBioOpenSession "WinBioOpenSession" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; WinBioOpenSession Factor, PoolType, Flags, varptr(UnitArray), UnitCount, varptr(DatabaseId), varptr(SessionHandle) ; 戻り値は stat
; Factor : DWORD -> "sptr"
; PoolType : WINBIO_POOL -> "sptr"
; Flags : DWORD -> "sptr"
; UnitArray : DWORD* optional -> "sptr"
; UnitCount : UINT_PTR optional -> "sptr"
; DatabaseId : GUID* optional -> "sptr"
; SessionHandle : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "winbio.dll" #cfunc global WinBioOpenSession "WinBioOpenSession" int, int, int, var, sptr, var, var ; res = WinBioOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, SessionHandle) ; Factor : DWORD -> "int" ; PoolType : WINBIO_POOL -> "int" ; Flags : DWORD -> "int" ; UnitArray : DWORD* optional -> "var" ; UnitCount : UINT_PTR optional -> "sptr" ; DatabaseId : GUID* optional -> "var" ; SessionHandle : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "winbio.dll" #cfunc global WinBioOpenSession "WinBioOpenSession" int, int, int, sptr, sptr, sptr, sptr ; res = WinBioOpenSession(Factor, PoolType, Flags, varptr(UnitArray), UnitCount, varptr(DatabaseId), varptr(SessionHandle)) ; Factor : DWORD -> "int" ; PoolType : WINBIO_POOL -> "int" ; Flags : DWORD -> "int" ; UnitArray : DWORD* optional -> "sptr" ; UnitCount : UINT_PTR optional -> "sptr" ; DatabaseId : GUID* optional -> "sptr" ; SessionHandle : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT WinBioOpenSession(DWORD Factor, WINBIO_POOL PoolType, DWORD Flags, DWORD* UnitArray, UINT_PTR UnitCount, GUID* DatabaseId, DWORD* SessionHandle) #uselib "winbio.dll" #cfunc global WinBioOpenSession "WinBioOpenSession" int, int, int, var, intptr, var, var ; res = WinBioOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, SessionHandle) ; Factor : DWORD -> "int" ; PoolType : WINBIO_POOL -> "int" ; Flags : DWORD -> "int" ; UnitArray : DWORD* optional -> "var" ; UnitCount : UINT_PTR optional -> "intptr" ; DatabaseId : GUID* optional -> "var" ; SessionHandle : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WinBioOpenSession(DWORD Factor, WINBIO_POOL PoolType, DWORD Flags, DWORD* UnitArray, UINT_PTR UnitCount, GUID* DatabaseId, DWORD* SessionHandle) #uselib "winbio.dll" #cfunc global WinBioOpenSession "WinBioOpenSession" int, int, int, intptr, intptr, intptr, intptr ; res = WinBioOpenSession(Factor, PoolType, Flags, varptr(UnitArray), UnitCount, varptr(DatabaseId), varptr(SessionHandle)) ; Factor : DWORD -> "int" ; PoolType : WINBIO_POOL -> "int" ; Flags : DWORD -> "int" ; UnitArray : DWORD* optional -> "intptr" ; UnitCount : UINT_PTR optional -> "intptr" ; DatabaseId : GUID* optional -> "intptr" ; SessionHandle : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winbio = windows.NewLazySystemDLL("winbio.dll")
procWinBioOpenSession = winbio.NewProc("WinBioOpenSession")
)
// Factor (DWORD), PoolType (WINBIO_POOL), Flags (DWORD), UnitArray (DWORD* optional), UnitCount (UINT_PTR optional), DatabaseId (GUID* optional), SessionHandle (DWORD* out)
r1, _, err := procWinBioOpenSession.Call(
uintptr(Factor),
uintptr(PoolType),
uintptr(Flags),
uintptr(UnitArray),
uintptr(UnitCount),
uintptr(DatabaseId),
uintptr(SessionHandle),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WinBioOpenSession(
Factor: DWORD; // DWORD
PoolType: DWORD; // WINBIO_POOL
Flags: DWORD; // DWORD
UnitArray: Pointer; // DWORD* optional
UnitCount: NativeUInt; // UINT_PTR optional
DatabaseId: PGUID; // GUID* optional
SessionHandle: Pointer // DWORD* out
): Integer; stdcall;
external 'winbio.dll' name 'WinBioOpenSession';result := DllCall("winbio\WinBioOpenSession"
, "UInt", Factor ; DWORD
, "UInt", PoolType ; WINBIO_POOL
, "UInt", Flags ; DWORD
, "Ptr", UnitArray ; DWORD* optional
, "UPtr", UnitCount ; UINT_PTR optional
, "Ptr", DatabaseId ; GUID* optional
, "Ptr", SessionHandle ; DWORD* out
, "Int") ; return: HRESULT●WinBioOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, SessionHandle) = DLL("winbio.dll", "int WinBioOpenSession(dword, dword, dword, void*, int, void*, void*)")
# 呼び出し: WinBioOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, SessionHandle)
# Factor : DWORD -> "dword"
# PoolType : WINBIO_POOL -> "dword"
# Flags : DWORD -> "dword"
# UnitArray : DWORD* optional -> "void*"
# UnitCount : UINT_PTR optional -> "int"
# DatabaseId : GUID* optional -> "void*"
# SessionHandle : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "winbio" fn WinBioOpenSession(
Factor: u32, // DWORD
PoolType: u32, // WINBIO_POOL
Flags: u32, // DWORD
UnitArray: [*c]u32, // DWORD* optional
UnitCount: usize, // UINT_PTR optional
DatabaseId: [*c]GUID, // GUID* optional
SessionHandle: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;proc WinBioOpenSession(
Factor: uint32, # DWORD
PoolType: uint32, # WINBIO_POOL
Flags: uint32, # DWORD
UnitArray: ptr uint32, # DWORD* optional
UnitCount: uint, # UINT_PTR optional
DatabaseId: ptr GUID, # GUID* optional
SessionHandle: ptr uint32 # DWORD* out
): int32 {.importc: "WinBioOpenSession", stdcall, dynlib: "winbio.dll".}pragma(lib, "winbio");
extern(Windows)
int WinBioOpenSession(
uint Factor, // DWORD
uint PoolType, // WINBIO_POOL
uint Flags, // DWORD
uint* UnitArray, // DWORD* optional
size_t UnitCount, // UINT_PTR optional
GUID* DatabaseId, // GUID* optional
uint* SessionHandle // DWORD* out
);ccall((:WinBioOpenSession, "winbio.dll"), stdcall, Int32,
(UInt32, UInt32, UInt32, Ptr{UInt32}, Csize_t, Ptr{GUID}, Ptr{UInt32}),
Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, SessionHandle)
# Factor : DWORD -> UInt32
# PoolType : WINBIO_POOL -> UInt32
# Flags : DWORD -> UInt32
# UnitArray : DWORD* optional -> Ptr{UInt32}
# UnitCount : UINT_PTR optional -> Csize_t
# DatabaseId : GUID* optional -> Ptr{GUID}
# SessionHandle : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WinBioOpenSession(
uint32_t Factor,
uint32_t PoolType,
uint32_t Flags,
uint32_t* UnitArray,
uintptr_t UnitCount,
void* DatabaseId,
uint32_t* SessionHandle);
]]
local winbio = ffi.load("winbio")
-- winbio.WinBioOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, SessionHandle)
-- Factor : DWORD
-- PoolType : WINBIO_POOL
-- Flags : DWORD
-- UnitArray : DWORD* optional
-- UnitCount : UINT_PTR optional
-- DatabaseId : GUID* optional
-- SessionHandle : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('winbio.dll');
const WinBioOpenSession = lib.func('__stdcall', 'WinBioOpenSession', 'int32_t', ['uint32_t', 'uint32_t', 'uint32_t', 'uint32_t *', 'uintptr_t', 'void *', 'uint32_t *']);
// WinBioOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, SessionHandle)
// Factor : DWORD -> 'uint32_t'
// PoolType : WINBIO_POOL -> 'uint32_t'
// Flags : DWORD -> 'uint32_t'
// UnitArray : DWORD* optional -> 'uint32_t *'
// UnitCount : UINT_PTR optional -> 'uintptr_t'
// DatabaseId : GUID* optional -> 'void *'
// SessionHandle : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("winbio.dll", {
WinBioOpenSession: { parameters: ["u32", "u32", "u32", "pointer", "usize", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WinBioOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, SessionHandle)
// Factor : DWORD -> "u32"
// PoolType : WINBIO_POOL -> "u32"
// Flags : DWORD -> "u32"
// UnitArray : DWORD* optional -> "pointer"
// UnitCount : UINT_PTR optional -> "usize"
// DatabaseId : GUID* optional -> "pointer"
// SessionHandle : DWORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WinBioOpenSession(
uint32_t Factor,
uint32_t PoolType,
uint32_t Flags,
uint32_t* UnitArray,
size_t UnitCount,
void* DatabaseId,
uint32_t* SessionHandle);
C, "winbio.dll");
// $ffi->WinBioOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, SessionHandle);
// Factor : DWORD
// PoolType : WINBIO_POOL
// Flags : DWORD
// UnitArray : DWORD* optional
// UnitCount : UINT_PTR optional
// DatabaseId : GUID* optional
// SessionHandle : DWORD* 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 WinBioOpenSession(
int Factor, // DWORD
int PoolType, // WINBIO_POOL
int Flags, // DWORD
IntByReference UnitArray, // DWORD* optional
long UnitCount, // UINT_PTR optional
Pointer DatabaseId, // GUID* optional
IntByReference SessionHandle // DWORD* out
);
}@[Link("winbio")]
lib Libwinbio
fun WinBioOpenSession = WinBioOpenSession(
Factor : UInt32, # DWORD
PoolType : UInt32, # WINBIO_POOL
Flags : UInt32, # DWORD
UnitArray : UInt32*, # DWORD* optional
UnitCount : LibC::SizeT, # UINT_PTR optional
DatabaseId : GUID*, # GUID* optional
SessionHandle : UInt32* # DWORD* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WinBioOpenSessionNative = Int32 Function(Uint32, Uint32, Uint32, Pointer<Uint32>, UintPtr, Pointer<Void>, Pointer<Uint32>);
typedef WinBioOpenSessionDart = int Function(int, int, int, Pointer<Uint32>, int, Pointer<Void>, Pointer<Uint32>);
final WinBioOpenSession = DynamicLibrary.open('winbio.dll')
.lookupFunction<WinBioOpenSessionNative, WinBioOpenSessionDart>('WinBioOpenSession');
// Factor : DWORD -> Uint32
// PoolType : WINBIO_POOL -> Uint32
// Flags : DWORD -> Uint32
// UnitArray : DWORD* optional -> Pointer<Uint32>
// UnitCount : UINT_PTR optional -> UintPtr
// DatabaseId : GUID* optional -> Pointer<Void>
// SessionHandle : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WinBioOpenSession(
Factor: DWORD; // DWORD
PoolType: DWORD; // WINBIO_POOL
Flags: DWORD; // DWORD
UnitArray: Pointer; // DWORD* optional
UnitCount: NativeUInt; // UINT_PTR optional
DatabaseId: PGUID; // GUID* optional
SessionHandle: Pointer // DWORD* out
): Integer; stdcall;
external 'winbio.dll' name 'WinBioOpenSession';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WinBioOpenSession"
c_WinBioOpenSession :: Word32 -> Word32 -> Word32 -> Ptr Word32 -> CUIntPtr -> Ptr () -> Ptr Word32 -> IO Int32
-- Factor : DWORD -> Word32
-- PoolType : WINBIO_POOL -> Word32
-- Flags : DWORD -> Word32
-- UnitArray : DWORD* optional -> Ptr Word32
-- UnitCount : UINT_PTR optional -> CUIntPtr
-- DatabaseId : GUID* optional -> Ptr ()
-- SessionHandle : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let winbioopensession =
foreign "WinBioOpenSession"
(uint32_t @-> uint32_t @-> uint32_t @-> (ptr uint32_t) @-> size_t @-> (ptr void) @-> (ptr uint32_t) @-> returning int32_t)
(* Factor : DWORD -> uint32_t *)
(* PoolType : WINBIO_POOL -> uint32_t *)
(* Flags : DWORD -> uint32_t *)
(* UnitArray : DWORD* optional -> (ptr uint32_t) *)
(* UnitCount : UINT_PTR optional -> size_t *)
(* DatabaseId : GUID* optional -> (ptr void) *)
(* SessionHandle : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library winbio (t "winbio.dll"))
(cffi:use-foreign-library winbio)
(cffi:defcfun ("WinBioOpenSession" win-bio-open-session :convention :stdcall) :int32
(factor :uint32) ; DWORD
(pool-type :uint32) ; WINBIO_POOL
(flags :uint32) ; DWORD
(unit-array :pointer) ; DWORD* optional
(unit-count :uint64) ; UINT_PTR optional
(database-id :pointer) ; GUID* optional
(session-handle :pointer)) ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WinBioOpenSession = Win32::API::More->new('winbio',
'int WinBioOpenSession(DWORD Factor, DWORD PoolType, DWORD Flags, LPVOID UnitArray, WPARAM UnitCount, LPVOID DatabaseId, LPVOID SessionHandle)');
# my $ret = $WinBioOpenSession->Call($Factor, $PoolType, $Flags, $UnitArray, $UnitCount, $DatabaseId, $SessionHandle);
# Factor : DWORD -> DWORD
# PoolType : WINBIO_POOL -> DWORD
# Flags : DWORD -> DWORD
# UnitArray : DWORD* optional -> LPVOID
# UnitCount : UINT_PTR optional -> WPARAM
# DatabaseId : GUID* optional -> LPVOID
# SessionHandle : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型