ホーム › Devices.BiometricFramework › WinBioIdentifyWithCallback
WinBioIdentifyWithCallback
関数コールバック方式で生体情報から利用者を識別する。
シグネチャ
// winbio.dll
#include <windows.h>
HRESULT WinBioIdentifyWithCallback(
DWORD SessionHandle,
PWINBIO_IDENTIFY_CALLBACK IdentifyCallback,
void* IdentifyCallbackContext // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| SessionHandle | DWORD | in | 識別に用いるセッションのハンドル。 |
| IdentifyCallback | PWINBIO_IDENTIFY_CALLBACK | in | 識別完了時に呼ばれるコールバック関数へのポインタ。 |
| IdentifyCallbackContext | void* | inoptional | コールバックに渡される任意のコンテキストポインタ。NULL可。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// winbio.dll
#include <windows.h>
HRESULT WinBioIdentifyWithCallback(
DWORD SessionHandle,
PWINBIO_IDENTIFY_CALLBACK IdentifyCallback,
void* IdentifyCallbackContext // optional
);[DllImport("winbio.dll", ExactSpelling = true)]
static extern int WinBioIdentifyWithCallback(
uint SessionHandle, // DWORD
IntPtr IdentifyCallback, // PWINBIO_IDENTIFY_CALLBACK
IntPtr IdentifyCallbackContext // void* optional
);<DllImport("winbio.dll", ExactSpelling:=True)>
Public Shared Function WinBioIdentifyWithCallback(
SessionHandle As UInteger, ' DWORD
IdentifyCallback As IntPtr, ' PWINBIO_IDENTIFY_CALLBACK
IdentifyCallbackContext As IntPtr ' void* optional
) As Integer
End Function' SessionHandle : DWORD
' IdentifyCallback : PWINBIO_IDENTIFY_CALLBACK
' IdentifyCallbackContext : void* optional
Declare PtrSafe Function WinBioIdentifyWithCallback Lib "winbio" ( _
ByVal SessionHandle As Long, _
ByVal IdentifyCallback As LongPtr, _
ByVal IdentifyCallbackContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WinBioIdentifyWithCallback = ctypes.windll.winbio.WinBioIdentifyWithCallback
WinBioIdentifyWithCallback.restype = ctypes.c_int
WinBioIdentifyWithCallback.argtypes = [
wintypes.DWORD, # SessionHandle : DWORD
ctypes.c_void_p, # IdentifyCallback : PWINBIO_IDENTIFY_CALLBACK
ctypes.POINTER(None), # IdentifyCallbackContext : void* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('winbio.dll')
WinBioIdentifyWithCallback = Fiddle::Function.new(
lib['WinBioIdentifyWithCallback'],
[
-Fiddle::TYPE_INT, # SessionHandle : DWORD
Fiddle::TYPE_VOIDP, # IdentifyCallback : PWINBIO_IDENTIFY_CALLBACK
Fiddle::TYPE_VOIDP, # IdentifyCallbackContext : void* optional
],
Fiddle::TYPE_INT)#[link(name = "winbio")]
extern "system" {
fn WinBioIdentifyWithCallback(
SessionHandle: u32, // DWORD
IdentifyCallback: *const core::ffi::c_void, // PWINBIO_IDENTIFY_CALLBACK
IdentifyCallbackContext: *mut () // void* optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("winbio.dll")]
public static extern int WinBioIdentifyWithCallback(uint SessionHandle, IntPtr IdentifyCallback, IntPtr IdentifyCallbackContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winbio_WinBioIdentifyWithCallback' -Namespace Win32 -PassThru
# $api::WinBioIdentifyWithCallback(SessionHandle, IdentifyCallback, IdentifyCallbackContext)#uselib "winbio.dll"
#func global WinBioIdentifyWithCallback "WinBioIdentifyWithCallback" sptr, sptr, sptr
; WinBioIdentifyWithCallback SessionHandle, IdentifyCallback, IdentifyCallbackContext ; 戻り値は stat
; SessionHandle : DWORD -> "sptr"
; IdentifyCallback : PWINBIO_IDENTIFY_CALLBACK -> "sptr"
; IdentifyCallbackContext : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "winbio.dll"
#cfunc global WinBioIdentifyWithCallback "WinBioIdentifyWithCallback" int, sptr, sptr
; res = WinBioIdentifyWithCallback(SessionHandle, IdentifyCallback, IdentifyCallbackContext)
; SessionHandle : DWORD -> "int"
; IdentifyCallback : PWINBIO_IDENTIFY_CALLBACK -> "sptr"
; IdentifyCallbackContext : void* optional -> "sptr"; HRESULT WinBioIdentifyWithCallback(DWORD SessionHandle, PWINBIO_IDENTIFY_CALLBACK IdentifyCallback, void* IdentifyCallbackContext)
#uselib "winbio.dll"
#cfunc global WinBioIdentifyWithCallback "WinBioIdentifyWithCallback" int, intptr, intptr
; res = WinBioIdentifyWithCallback(SessionHandle, IdentifyCallback, IdentifyCallbackContext)
; SessionHandle : DWORD -> "int"
; IdentifyCallback : PWINBIO_IDENTIFY_CALLBACK -> "intptr"
; IdentifyCallbackContext : void* optional -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winbio = windows.NewLazySystemDLL("winbio.dll")
procWinBioIdentifyWithCallback = winbio.NewProc("WinBioIdentifyWithCallback")
)
// SessionHandle (DWORD), IdentifyCallback (PWINBIO_IDENTIFY_CALLBACK), IdentifyCallbackContext (void* optional)
r1, _, err := procWinBioIdentifyWithCallback.Call(
uintptr(SessionHandle),
uintptr(IdentifyCallback),
uintptr(IdentifyCallbackContext),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WinBioIdentifyWithCallback(
SessionHandle: DWORD; // DWORD
IdentifyCallback: Pointer; // PWINBIO_IDENTIFY_CALLBACK
IdentifyCallbackContext: Pointer // void* optional
): Integer; stdcall;
external 'winbio.dll' name 'WinBioIdentifyWithCallback';result := DllCall("winbio\WinBioIdentifyWithCallback"
, "UInt", SessionHandle ; DWORD
, "Ptr", IdentifyCallback ; PWINBIO_IDENTIFY_CALLBACK
, "Ptr", IdentifyCallbackContext ; void* optional
, "Int") ; return: HRESULT●WinBioIdentifyWithCallback(SessionHandle, IdentifyCallback, IdentifyCallbackContext) = DLL("winbio.dll", "int WinBioIdentifyWithCallback(dword, void*, void*)")
# 呼び出し: WinBioIdentifyWithCallback(SessionHandle, IdentifyCallback, IdentifyCallbackContext)
# SessionHandle : DWORD -> "dword"
# IdentifyCallback : PWINBIO_IDENTIFY_CALLBACK -> "void*"
# IdentifyCallbackContext : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "winbio" fn WinBioIdentifyWithCallback(
SessionHandle: u32, // DWORD
IdentifyCallback: ?*anyopaque, // PWINBIO_IDENTIFY_CALLBACK
IdentifyCallbackContext: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) i32;proc WinBioIdentifyWithCallback(
SessionHandle: uint32, # DWORD
IdentifyCallback: pointer, # PWINBIO_IDENTIFY_CALLBACK
IdentifyCallbackContext: pointer # void* optional
): int32 {.importc: "WinBioIdentifyWithCallback", stdcall, dynlib: "winbio.dll".}pragma(lib, "winbio");
extern(Windows)
int WinBioIdentifyWithCallback(
uint SessionHandle, // DWORD
void* IdentifyCallback, // PWINBIO_IDENTIFY_CALLBACK
void* IdentifyCallbackContext // void* optional
);ccall((:WinBioIdentifyWithCallback, "winbio.dll"), stdcall, Int32,
(UInt32, Ptr{Cvoid}, Ptr{Cvoid}),
SessionHandle, IdentifyCallback, IdentifyCallbackContext)
# SessionHandle : DWORD -> UInt32
# IdentifyCallback : PWINBIO_IDENTIFY_CALLBACK -> Ptr{Cvoid}
# IdentifyCallbackContext : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WinBioIdentifyWithCallback(
uint32_t SessionHandle,
void* IdentifyCallback,
void* IdentifyCallbackContext);
]]
local winbio = ffi.load("winbio")
-- winbio.WinBioIdentifyWithCallback(SessionHandle, IdentifyCallback, IdentifyCallbackContext)
-- SessionHandle : DWORD
-- IdentifyCallback : PWINBIO_IDENTIFY_CALLBACK
-- IdentifyCallbackContext : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('winbio.dll');
const WinBioIdentifyWithCallback = lib.func('__stdcall', 'WinBioIdentifyWithCallback', 'int32_t', ['uint32_t', 'void *', 'void *']);
// WinBioIdentifyWithCallback(SessionHandle, IdentifyCallback, IdentifyCallbackContext)
// SessionHandle : DWORD -> 'uint32_t'
// IdentifyCallback : PWINBIO_IDENTIFY_CALLBACK -> 'void *'
// IdentifyCallbackContext : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。const lib = Deno.dlopen("winbio.dll", {
WinBioIdentifyWithCallback: { parameters: ["u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WinBioIdentifyWithCallback(SessionHandle, IdentifyCallback, IdentifyCallbackContext)
// SessionHandle : DWORD -> "u32"
// IdentifyCallback : PWINBIO_IDENTIFY_CALLBACK -> "pointer"
// IdentifyCallbackContext : void* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WinBioIdentifyWithCallback(
uint32_t SessionHandle,
void* IdentifyCallback,
void* IdentifyCallbackContext);
C, "winbio.dll");
// $ffi->WinBioIdentifyWithCallback(SessionHandle, IdentifyCallback, IdentifyCallbackContext);
// SessionHandle : DWORD
// IdentifyCallback : PWINBIO_IDENTIFY_CALLBACK
// IdentifyCallbackContext : void* optional
// 構造体/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 WinBioIdentifyWithCallback(
int SessionHandle, // DWORD
Callback IdentifyCallback, // PWINBIO_IDENTIFY_CALLBACK
Pointer IdentifyCallbackContext // void* optional
);
}@[Link("winbio")]
lib Libwinbio
fun WinBioIdentifyWithCallback = WinBioIdentifyWithCallback(
SessionHandle : UInt32, # DWORD
IdentifyCallback : Void*, # PWINBIO_IDENTIFY_CALLBACK
IdentifyCallbackContext : Void* # void* optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WinBioIdentifyWithCallbackNative = Int32 Function(Uint32, Pointer<Void>, Pointer<Void>);
typedef WinBioIdentifyWithCallbackDart = int Function(int, Pointer<Void>, Pointer<Void>);
final WinBioIdentifyWithCallback = DynamicLibrary.open('winbio.dll')
.lookupFunction<WinBioIdentifyWithCallbackNative, WinBioIdentifyWithCallbackDart>('WinBioIdentifyWithCallback');
// SessionHandle : DWORD -> Uint32
// IdentifyCallback : PWINBIO_IDENTIFY_CALLBACK -> Pointer<Void>
// IdentifyCallbackContext : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WinBioIdentifyWithCallback(
SessionHandle: DWORD; // DWORD
IdentifyCallback: Pointer; // PWINBIO_IDENTIFY_CALLBACK
IdentifyCallbackContext: Pointer // void* optional
): Integer; stdcall;
external 'winbio.dll' name 'WinBioIdentifyWithCallback';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WinBioIdentifyWithCallback"
c_WinBioIdentifyWithCallback :: Word32 -> Ptr () -> Ptr () -> IO Int32
-- SessionHandle : DWORD -> Word32
-- IdentifyCallback : PWINBIO_IDENTIFY_CALLBACK -> Ptr ()
-- IdentifyCallbackContext : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let winbioidentifywithcallback =
foreign "WinBioIdentifyWithCallback"
(uint32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* SessionHandle : DWORD -> uint32_t *)
(* IdentifyCallback : PWINBIO_IDENTIFY_CALLBACK -> (ptr void) *)
(* IdentifyCallbackContext : void* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library winbio (t "winbio.dll"))
(cffi:use-foreign-library winbio)
(cffi:defcfun ("WinBioIdentifyWithCallback" win-bio-identify-with-callback :convention :stdcall) :int32
(session-handle :uint32) ; DWORD
(identify-callback :pointer) ; PWINBIO_IDENTIFY_CALLBACK
(identify-callback-context :pointer)) ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WinBioIdentifyWithCallback = Win32::API::More->new('winbio',
'int WinBioIdentifyWithCallback(DWORD SessionHandle, LPVOID IdentifyCallback, LPVOID IdentifyCallbackContext)');
# my $ret = $WinBioIdentifyWithCallback->Call($SessionHandle, $IdentifyCallback, $IdentifyCallbackContext);
# SessionHandle : DWORD -> DWORD
# IdentifyCallback : PWINBIO_IDENTIFY_CALLBACK -> LPVOID
# IdentifyCallbackContext : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。