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

WinBioAsyncOpenSession

関数
生体認証操作用の非同期セッションを開く。
DLLwinbio.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT WinBioAsyncOpenSession(
    DWORD Factor,
    WINBIO_POOL PoolType,
    DWORD Flags,
    DWORD* UnitArray,   // optional
    UINT_PTR UnitCount,   // optional
    GUID* DatabaseId,   // optional
    WINBIO_ASYNC_NOTIFICATION_METHOD NotificationMethod,
    HWND TargetWindow,   // optional
    DWORD MessageCode,   // optional
    PWINBIO_ASYNC_COMPLETION_CALLBACK CallbackRoutine,   // optional
    void* UserData,   // optional
    BOOL AsynchronousOpen,
    DWORD* SessionHandle   // optional
);

パラメーター

名前方向説明
FactorDWORDinセッションで扱う生体認証ファクターを表すフラグ。WINBIO_TYPE値の組み合わせ。
PoolTypeWINBIO_POOLin使用するユニットプールの種類(システム/プライベート)を指定。
FlagsDWORDinセッションの動作を制御するフラグ。WINBIO_FLAG_RAW/DEFAULT等。
UnitArrayDWORD*inoptionalプライベートプール使用時に対象とするユニットIDの配列。システムプールではNULL可。
UnitCountUINT_PTRinoptionalUnitArrayの要素数。システムプールでは0。
DatabaseIdGUID*inoptionalプライベートプール使用時のデータベースGUIDへのポインタ。システムプールではNULL可。
NotificationMethodWINBIO_ASYNC_NOTIFICATION_METHODin完了通知の方式(ウィンドウメッセージ/コールバック)を指定する列挙値。
TargetWindowHWNDinoptionalウィンドウメッセージ方式で通知を受け取るウィンドウハンドル。コールバック方式ではNULL可。
MessageCodeDWORDinoptionalウィンドウメッセージ方式で送信するメッセージコード。WM_USER以上の値。
CallbackRoutinePWINBIO_ASYNC_COMPLETION_CALLBACKinoptionalコールバック方式で完了時に呼ばれる関数へのポインタ。
UserDatavoid*inoptionalコールバックや通知に渡される任意のユーザーデータポインタ。NULL可。
AsynchronousOpenBOOLinオープン処理自体を非同期で行うかを指定するブール値。TRUEで非同期。
SessionHandleDWORD*outoptional開いたセッションのハンドルを受け取る出力ポインタ。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WinBioAsyncOpenSession(
    DWORD Factor,
    WINBIO_POOL PoolType,
    DWORD Flags,
    DWORD* UnitArray,   // optional
    UINT_PTR UnitCount,   // optional
    GUID* DatabaseId,   // optional
    WINBIO_ASYNC_NOTIFICATION_METHOD NotificationMethod,
    HWND TargetWindow,   // optional
    DWORD MessageCode,   // optional
    PWINBIO_ASYNC_COMPLETION_CALLBACK CallbackRoutine,   // optional
    void* UserData,   // optional
    BOOL AsynchronousOpen,
    DWORD* SessionHandle   // optional
);
[DllImport("winbio.dll", ExactSpelling = true)]
static extern int WinBioAsyncOpenSession(
    uint Factor,   // DWORD
    uint PoolType,   // WINBIO_POOL
    uint Flags,   // DWORD
    IntPtr UnitArray,   // DWORD* optional
    UIntPtr UnitCount,   // UINT_PTR optional
    IntPtr DatabaseId,   // GUID* optional
    int NotificationMethod,   // WINBIO_ASYNC_NOTIFICATION_METHOD
    IntPtr TargetWindow,   // HWND optional
    uint MessageCode,   // DWORD optional
    IntPtr CallbackRoutine,   // PWINBIO_ASYNC_COMPLETION_CALLBACK optional
    IntPtr UserData,   // void* optional
    bool AsynchronousOpen,   // BOOL
    IntPtr SessionHandle   // DWORD* optional, out
);
<DllImport("winbio.dll", ExactSpelling:=True)>
Public Shared Function WinBioAsyncOpenSession(
    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
    NotificationMethod As Integer,   ' WINBIO_ASYNC_NOTIFICATION_METHOD
    TargetWindow As IntPtr,   ' HWND optional
    MessageCode As UInteger,   ' DWORD optional
    CallbackRoutine As IntPtr,   ' PWINBIO_ASYNC_COMPLETION_CALLBACK optional
    UserData As IntPtr,   ' void* optional
    AsynchronousOpen As Boolean,   ' BOOL
    SessionHandle As IntPtr   ' DWORD* optional, out
) As Integer
End Function
' Factor : DWORD
' PoolType : WINBIO_POOL
' Flags : DWORD
' UnitArray : DWORD* optional
' UnitCount : UINT_PTR optional
' DatabaseId : GUID* optional
' NotificationMethod : WINBIO_ASYNC_NOTIFICATION_METHOD
' TargetWindow : HWND optional
' MessageCode : DWORD optional
' CallbackRoutine : PWINBIO_ASYNC_COMPLETION_CALLBACK optional
' UserData : void* optional
' AsynchronousOpen : BOOL
' SessionHandle : DWORD* optional, out
Declare PtrSafe Function WinBioAsyncOpenSession 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, _
    ByVal NotificationMethod As Long, _
    ByVal TargetWindow As LongPtr, _
    ByVal MessageCode As Long, _
    ByVal CallbackRoutine As LongPtr, _
    ByVal UserData As LongPtr, _
    ByVal AsynchronousOpen As Long, _
    ByVal SessionHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WinBioAsyncOpenSession = ctypes.windll.winbio.WinBioAsyncOpenSession
WinBioAsyncOpenSession.restype = ctypes.c_int
WinBioAsyncOpenSession.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.c_int,  # NotificationMethod : WINBIO_ASYNC_NOTIFICATION_METHOD
    wintypes.HANDLE,  # TargetWindow : HWND optional
    wintypes.DWORD,  # MessageCode : DWORD optional
    ctypes.c_void_p,  # CallbackRoutine : PWINBIO_ASYNC_COMPLETION_CALLBACK optional
    ctypes.POINTER(None),  # UserData : void* optional
    wintypes.BOOL,  # AsynchronousOpen : BOOL
    ctypes.POINTER(wintypes.DWORD),  # SessionHandle : DWORD* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('winbio.dll')
WinBioAsyncOpenSession = Fiddle::Function.new(
  lib['WinBioAsyncOpenSession'],
  [
    -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_INT,  # NotificationMethod : WINBIO_ASYNC_NOTIFICATION_METHOD
    Fiddle::TYPE_VOIDP,  # TargetWindow : HWND optional
    -Fiddle::TYPE_INT,  # MessageCode : DWORD optional
    Fiddle::TYPE_VOIDP,  # CallbackRoutine : PWINBIO_ASYNC_COMPLETION_CALLBACK optional
    Fiddle::TYPE_VOIDP,  # UserData : void* optional
    Fiddle::TYPE_INT,  # AsynchronousOpen : BOOL
    Fiddle::TYPE_VOIDP,  # SessionHandle : DWORD* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "winbio")]
extern "system" {
    fn WinBioAsyncOpenSession(
        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
        NotificationMethod: i32,  // WINBIO_ASYNC_NOTIFICATION_METHOD
        TargetWindow: *mut core::ffi::c_void,  // HWND optional
        MessageCode: u32,  // DWORD optional
        CallbackRoutine: *const core::ffi::c_void,  // PWINBIO_ASYNC_COMPLETION_CALLBACK optional
        UserData: *mut (),  // void* optional
        AsynchronousOpen: i32,  // BOOL
        SessionHandle: *mut u32  // DWORD* optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("winbio.dll")]
public static extern int WinBioAsyncOpenSession(uint Factor, uint PoolType, uint Flags, IntPtr UnitArray, UIntPtr UnitCount, IntPtr DatabaseId, int NotificationMethod, IntPtr TargetWindow, uint MessageCode, IntPtr CallbackRoutine, IntPtr UserData, bool AsynchronousOpen, IntPtr SessionHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winbio_WinBioAsyncOpenSession' -Namespace Win32 -PassThru
# $api::WinBioAsyncOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, NotificationMethod, TargetWindow, MessageCode, CallbackRoutine, UserData, AsynchronousOpen, SessionHandle)
#uselib "winbio.dll"
#func global WinBioAsyncOpenSession "WinBioAsyncOpenSession" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; WinBioAsyncOpenSession Factor, PoolType, Flags, varptr(UnitArray), UnitCount, varptr(DatabaseId), NotificationMethod, TargetWindow, MessageCode, CallbackRoutine, UserData, AsynchronousOpen, 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"
; NotificationMethod : WINBIO_ASYNC_NOTIFICATION_METHOD -> "sptr"
; TargetWindow : HWND optional -> "sptr"
; MessageCode : DWORD optional -> "sptr"
; CallbackRoutine : PWINBIO_ASYNC_COMPLETION_CALLBACK optional -> "sptr"
; UserData : void* optional -> "sptr"
; AsynchronousOpen : BOOL -> "sptr"
; SessionHandle : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "winbio.dll"
#cfunc global WinBioAsyncOpenSession "WinBioAsyncOpenSession" int, int, int, var, sptr, var, int, sptr, int, sptr, sptr, int, var
; res = WinBioAsyncOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, NotificationMethod, TargetWindow, MessageCode, CallbackRoutine, UserData, AsynchronousOpen, SessionHandle)
; Factor : DWORD -> "int"
; PoolType : WINBIO_POOL -> "int"
; Flags : DWORD -> "int"
; UnitArray : DWORD* optional -> "var"
; UnitCount : UINT_PTR optional -> "sptr"
; DatabaseId : GUID* optional -> "var"
; NotificationMethod : WINBIO_ASYNC_NOTIFICATION_METHOD -> "int"
; TargetWindow : HWND optional -> "sptr"
; MessageCode : DWORD optional -> "int"
; CallbackRoutine : PWINBIO_ASYNC_COMPLETION_CALLBACK optional -> "sptr"
; UserData : void* optional -> "sptr"
; AsynchronousOpen : BOOL -> "int"
; SessionHandle : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WinBioAsyncOpenSession(DWORD Factor, WINBIO_POOL PoolType, DWORD Flags, DWORD* UnitArray, UINT_PTR UnitCount, GUID* DatabaseId, WINBIO_ASYNC_NOTIFICATION_METHOD NotificationMethod, HWND TargetWindow, DWORD MessageCode, PWINBIO_ASYNC_COMPLETION_CALLBACK CallbackRoutine, void* UserData, BOOL AsynchronousOpen, DWORD* SessionHandle)
#uselib "winbio.dll"
#cfunc global WinBioAsyncOpenSession "WinBioAsyncOpenSession" int, int, int, var, intptr, var, int, intptr, int, intptr, intptr, int, var
; res = WinBioAsyncOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, NotificationMethod, TargetWindow, MessageCode, CallbackRoutine, UserData, AsynchronousOpen, SessionHandle)
; Factor : DWORD -> "int"
; PoolType : WINBIO_POOL -> "int"
; Flags : DWORD -> "int"
; UnitArray : DWORD* optional -> "var"
; UnitCount : UINT_PTR optional -> "intptr"
; DatabaseId : GUID* optional -> "var"
; NotificationMethod : WINBIO_ASYNC_NOTIFICATION_METHOD -> "int"
; TargetWindow : HWND optional -> "intptr"
; MessageCode : DWORD optional -> "int"
; CallbackRoutine : PWINBIO_ASYNC_COMPLETION_CALLBACK optional -> "intptr"
; UserData : void* optional -> "intptr"
; AsynchronousOpen : BOOL -> "int"
; SessionHandle : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winbio = windows.NewLazySystemDLL("winbio.dll")
	procWinBioAsyncOpenSession = winbio.NewProc("WinBioAsyncOpenSession")
)

// Factor (DWORD), PoolType (WINBIO_POOL), Flags (DWORD), UnitArray (DWORD* optional), UnitCount (UINT_PTR optional), DatabaseId (GUID* optional), NotificationMethod (WINBIO_ASYNC_NOTIFICATION_METHOD), TargetWindow (HWND optional), MessageCode (DWORD optional), CallbackRoutine (PWINBIO_ASYNC_COMPLETION_CALLBACK optional), UserData (void* optional), AsynchronousOpen (BOOL), SessionHandle (DWORD* optional, out)
r1, _, err := procWinBioAsyncOpenSession.Call(
	uintptr(Factor),
	uintptr(PoolType),
	uintptr(Flags),
	uintptr(UnitArray),
	uintptr(UnitCount),
	uintptr(DatabaseId),
	uintptr(NotificationMethod),
	uintptr(TargetWindow),
	uintptr(MessageCode),
	uintptr(CallbackRoutine),
	uintptr(UserData),
	uintptr(AsynchronousOpen),
	uintptr(SessionHandle),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WinBioAsyncOpenSession(
  Factor: DWORD;   // DWORD
  PoolType: DWORD;   // WINBIO_POOL
  Flags: DWORD;   // DWORD
  UnitArray: Pointer;   // DWORD* optional
  UnitCount: NativeUInt;   // UINT_PTR optional
  DatabaseId: PGUID;   // GUID* optional
  NotificationMethod: Integer;   // WINBIO_ASYNC_NOTIFICATION_METHOD
  TargetWindow: THandle;   // HWND optional
  MessageCode: DWORD;   // DWORD optional
  CallbackRoutine: Pointer;   // PWINBIO_ASYNC_COMPLETION_CALLBACK optional
  UserData: Pointer;   // void* optional
  AsynchronousOpen: BOOL;   // BOOL
  SessionHandle: Pointer   // DWORD* optional, out
): Integer; stdcall;
  external 'winbio.dll' name 'WinBioAsyncOpenSession';
result := DllCall("winbio\WinBioAsyncOpenSession"
    , "UInt", Factor   ; DWORD
    , "UInt", PoolType   ; WINBIO_POOL
    , "UInt", Flags   ; DWORD
    , "Ptr", UnitArray   ; DWORD* optional
    , "UPtr", UnitCount   ; UINT_PTR optional
    , "Ptr", DatabaseId   ; GUID* optional
    , "Int", NotificationMethod   ; WINBIO_ASYNC_NOTIFICATION_METHOD
    , "Ptr", TargetWindow   ; HWND optional
    , "UInt", MessageCode   ; DWORD optional
    , "Ptr", CallbackRoutine   ; PWINBIO_ASYNC_COMPLETION_CALLBACK optional
    , "Ptr", UserData   ; void* optional
    , "Int", AsynchronousOpen   ; BOOL
    , "Ptr", SessionHandle   ; DWORD* optional, out
    , "Int")   ; return: HRESULT
●WinBioAsyncOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, NotificationMethod, TargetWindow, MessageCode, CallbackRoutine, UserData, AsynchronousOpen, SessionHandle) = DLL("winbio.dll", "int WinBioAsyncOpenSession(dword, dword, dword, void*, int, void*, int, void*, dword, void*, void*, bool, void*)")
# 呼び出し: WinBioAsyncOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, NotificationMethod, TargetWindow, MessageCode, CallbackRoutine, UserData, AsynchronousOpen, SessionHandle)
# Factor : DWORD -> "dword"
# PoolType : WINBIO_POOL -> "dword"
# Flags : DWORD -> "dword"
# UnitArray : DWORD* optional -> "void*"
# UnitCount : UINT_PTR optional -> "int"
# DatabaseId : GUID* optional -> "void*"
# NotificationMethod : WINBIO_ASYNC_NOTIFICATION_METHOD -> "int"
# TargetWindow : HWND optional -> "void*"
# MessageCode : DWORD optional -> "dword"
# CallbackRoutine : PWINBIO_ASYNC_COMPLETION_CALLBACK optional -> "void*"
# UserData : void* optional -> "void*"
# AsynchronousOpen : BOOL -> "bool"
# SessionHandle : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "winbio" fn WinBioAsyncOpenSession(
    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
    NotificationMethod: i32, // WINBIO_ASYNC_NOTIFICATION_METHOD
    TargetWindow: ?*anyopaque, // HWND optional
    MessageCode: u32, // DWORD optional
    CallbackRoutine: ?*anyopaque, // PWINBIO_ASYNC_COMPLETION_CALLBACK optional
    UserData: ?*anyopaque, // void* optional
    AsynchronousOpen: i32, // BOOL
    SessionHandle: [*c]u32 // DWORD* optional, out
) callconv(std.os.windows.WINAPI) i32;
proc WinBioAsyncOpenSession(
    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
    NotificationMethod: int32,  # WINBIO_ASYNC_NOTIFICATION_METHOD
    TargetWindow: pointer,  # HWND optional
    MessageCode: uint32,  # DWORD optional
    CallbackRoutine: pointer,  # PWINBIO_ASYNC_COMPLETION_CALLBACK optional
    UserData: pointer,  # void* optional
    AsynchronousOpen: int32,  # BOOL
    SessionHandle: ptr uint32  # DWORD* optional, out
): int32 {.importc: "WinBioAsyncOpenSession", stdcall, dynlib: "winbio.dll".}
pragma(lib, "winbio");
extern(Windows)
int WinBioAsyncOpenSession(
    uint Factor,   // DWORD
    uint PoolType,   // WINBIO_POOL
    uint Flags,   // DWORD
    uint* UnitArray,   // DWORD* optional
    size_t UnitCount,   // UINT_PTR optional
    GUID* DatabaseId,   // GUID* optional
    int NotificationMethod,   // WINBIO_ASYNC_NOTIFICATION_METHOD
    void* TargetWindow,   // HWND optional
    uint MessageCode,   // DWORD optional
    void* CallbackRoutine,   // PWINBIO_ASYNC_COMPLETION_CALLBACK optional
    void* UserData,   // void* optional
    int AsynchronousOpen,   // BOOL
    uint* SessionHandle   // DWORD* optional, out
);
ccall((:WinBioAsyncOpenSession, "winbio.dll"), stdcall, Int32,
      (UInt32, UInt32, UInt32, Ptr{UInt32}, Csize_t, Ptr{GUID}, Int32, Ptr{Cvoid}, UInt32, Ptr{Cvoid}, Ptr{Cvoid}, Int32, Ptr{UInt32}),
      Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, NotificationMethod, TargetWindow, MessageCode, CallbackRoutine, UserData, AsynchronousOpen, 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}
# NotificationMethod : WINBIO_ASYNC_NOTIFICATION_METHOD -> Int32
# TargetWindow : HWND optional -> Ptr{Cvoid}
# MessageCode : DWORD optional -> UInt32
# CallbackRoutine : PWINBIO_ASYNC_COMPLETION_CALLBACK optional -> Ptr{Cvoid}
# UserData : void* optional -> Ptr{Cvoid}
# AsynchronousOpen : BOOL -> Int32
# SessionHandle : DWORD* optional, out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WinBioAsyncOpenSession(
    uint32_t Factor,
    uint32_t PoolType,
    uint32_t Flags,
    uint32_t* UnitArray,
    uintptr_t UnitCount,
    void* DatabaseId,
    int32_t NotificationMethod,
    void* TargetWindow,
    uint32_t MessageCode,
    void* CallbackRoutine,
    void* UserData,
    int32_t AsynchronousOpen,
    uint32_t* SessionHandle);
]]
local winbio = ffi.load("winbio")
-- winbio.WinBioAsyncOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, NotificationMethod, TargetWindow, MessageCode, CallbackRoutine, UserData, AsynchronousOpen, SessionHandle)
-- Factor : DWORD
-- PoolType : WINBIO_POOL
-- Flags : DWORD
-- UnitArray : DWORD* optional
-- UnitCount : UINT_PTR optional
-- DatabaseId : GUID* optional
-- NotificationMethod : WINBIO_ASYNC_NOTIFICATION_METHOD
-- TargetWindow : HWND optional
-- MessageCode : DWORD optional
-- CallbackRoutine : PWINBIO_ASYNC_COMPLETION_CALLBACK optional
-- UserData : void* optional
-- AsynchronousOpen : BOOL
-- SessionHandle : DWORD* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('winbio.dll');
const WinBioAsyncOpenSession = lib.func('__stdcall', 'WinBioAsyncOpenSession', 'int32_t', ['uint32_t', 'uint32_t', 'uint32_t', 'uint32_t *', 'uintptr_t', 'void *', 'int32_t', 'void *', 'uint32_t', 'void *', 'void *', 'int32_t', 'uint32_t *']);
// WinBioAsyncOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, NotificationMethod, TargetWindow, MessageCode, CallbackRoutine, UserData, AsynchronousOpen, 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 *'
// NotificationMethod : WINBIO_ASYNC_NOTIFICATION_METHOD -> 'int32_t'
// TargetWindow : HWND optional -> 'void *'
// MessageCode : DWORD optional -> 'uint32_t'
// CallbackRoutine : PWINBIO_ASYNC_COMPLETION_CALLBACK optional -> 'void *'
// UserData : void* optional -> 'void *'
// AsynchronousOpen : BOOL -> 'int32_t'
// SessionHandle : DWORD* optional, out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。
const lib = Deno.dlopen("winbio.dll", {
  WinBioAsyncOpenSession: { parameters: ["u32", "u32", "u32", "pointer", "usize", "pointer", "i32", "pointer", "u32", "pointer", "pointer", "i32", "pointer"], result: "i32" },
});
// lib.symbols.WinBioAsyncOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, NotificationMethod, TargetWindow, MessageCode, CallbackRoutine, UserData, AsynchronousOpen, SessionHandle)
// Factor : DWORD -> "u32"
// PoolType : WINBIO_POOL -> "u32"
// Flags : DWORD -> "u32"
// UnitArray : DWORD* optional -> "pointer"
// UnitCount : UINT_PTR optional -> "usize"
// DatabaseId : GUID* optional -> "pointer"
// NotificationMethod : WINBIO_ASYNC_NOTIFICATION_METHOD -> "i32"
// TargetWindow : HWND optional -> "pointer"
// MessageCode : DWORD optional -> "u32"
// CallbackRoutine : PWINBIO_ASYNC_COMPLETION_CALLBACK optional -> "pointer"
// UserData : void* optional -> "pointer"
// AsynchronousOpen : BOOL -> "i32"
// SessionHandle : DWORD* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WinBioAsyncOpenSession(
    uint32_t Factor,
    uint32_t PoolType,
    uint32_t Flags,
    uint32_t* UnitArray,
    size_t UnitCount,
    void* DatabaseId,
    int32_t NotificationMethod,
    void* TargetWindow,
    uint32_t MessageCode,
    void* CallbackRoutine,
    void* UserData,
    int32_t AsynchronousOpen,
    uint32_t* SessionHandle);
C, "winbio.dll");
// $ffi->WinBioAsyncOpenSession(Factor, PoolType, Flags, UnitArray, UnitCount, DatabaseId, NotificationMethod, TargetWindow, MessageCode, CallbackRoutine, UserData, AsynchronousOpen, SessionHandle);
// Factor : DWORD
// PoolType : WINBIO_POOL
// Flags : DWORD
// UnitArray : DWORD* optional
// UnitCount : UINT_PTR optional
// DatabaseId : GUID* optional
// NotificationMethod : WINBIO_ASYNC_NOTIFICATION_METHOD
// TargetWindow : HWND optional
// MessageCode : DWORD optional
// CallbackRoutine : PWINBIO_ASYNC_COMPLETION_CALLBACK optional
// UserData : void* optional
// AsynchronousOpen : BOOL
// SessionHandle : DWORD* 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 WinBioAsyncOpenSession(
        int Factor,   // DWORD
        int PoolType,   // WINBIO_POOL
        int Flags,   // DWORD
        IntByReference UnitArray,   // DWORD* optional
        long UnitCount,   // UINT_PTR optional
        Pointer DatabaseId,   // GUID* optional
        int NotificationMethod,   // WINBIO_ASYNC_NOTIFICATION_METHOD
        Pointer TargetWindow,   // HWND optional
        int MessageCode,   // DWORD optional
        Callback CallbackRoutine,   // PWINBIO_ASYNC_COMPLETION_CALLBACK optional
        Pointer UserData,   // void* optional
        boolean AsynchronousOpen,   // BOOL
        IntByReference SessionHandle   // DWORD* optional, out
    );
}
@[Link("winbio")]
lib Libwinbio
  fun WinBioAsyncOpenSession = WinBioAsyncOpenSession(
    Factor : UInt32,   # DWORD
    PoolType : UInt32,   # WINBIO_POOL
    Flags : UInt32,   # DWORD
    UnitArray : UInt32*,   # DWORD* optional
    UnitCount : LibC::SizeT,   # UINT_PTR optional
    DatabaseId : GUID*,   # GUID* optional
    NotificationMethod : Int32,   # WINBIO_ASYNC_NOTIFICATION_METHOD
    TargetWindow : Void*,   # HWND optional
    MessageCode : UInt32,   # DWORD optional
    CallbackRoutine : Void*,   # PWINBIO_ASYNC_COMPLETION_CALLBACK optional
    UserData : Void*,   # void* optional
    AsynchronousOpen : Int32,   # BOOL
    SessionHandle : UInt32*   # DWORD* 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 WinBioAsyncOpenSessionNative = Int32 Function(Uint32, Uint32, Uint32, Pointer<Uint32>, UintPtr, Pointer<Void>, Int32, Pointer<Void>, Uint32, Pointer<Void>, Pointer<Void>, Int32, Pointer<Uint32>);
typedef WinBioAsyncOpenSessionDart = int Function(int, int, int, Pointer<Uint32>, int, Pointer<Void>, int, Pointer<Void>, int, Pointer<Void>, Pointer<Void>, int, Pointer<Uint32>);
final WinBioAsyncOpenSession = DynamicLibrary.open('winbio.dll')
    .lookupFunction<WinBioAsyncOpenSessionNative, WinBioAsyncOpenSessionDart>('WinBioAsyncOpenSession');
// 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>
// NotificationMethod : WINBIO_ASYNC_NOTIFICATION_METHOD -> Int32
// TargetWindow : HWND optional -> Pointer<Void>
// MessageCode : DWORD optional -> Uint32
// CallbackRoutine : PWINBIO_ASYNC_COMPLETION_CALLBACK optional -> Pointer<Void>
// UserData : void* optional -> Pointer<Void>
// AsynchronousOpen : BOOL -> Int32
// SessionHandle : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WinBioAsyncOpenSession(
  Factor: DWORD;   // DWORD
  PoolType: DWORD;   // WINBIO_POOL
  Flags: DWORD;   // DWORD
  UnitArray: Pointer;   // DWORD* optional
  UnitCount: NativeUInt;   // UINT_PTR optional
  DatabaseId: PGUID;   // GUID* optional
  NotificationMethod: Integer;   // WINBIO_ASYNC_NOTIFICATION_METHOD
  TargetWindow: THandle;   // HWND optional
  MessageCode: DWORD;   // DWORD optional
  CallbackRoutine: Pointer;   // PWINBIO_ASYNC_COMPLETION_CALLBACK optional
  UserData: Pointer;   // void* optional
  AsynchronousOpen: BOOL;   // BOOL
  SessionHandle: Pointer   // DWORD* optional, out
): Integer; stdcall;
  external 'winbio.dll' name 'WinBioAsyncOpenSession';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WinBioAsyncOpenSession"
  c_WinBioAsyncOpenSession :: Word32 -> Word32 -> Word32 -> Ptr Word32 -> CUIntPtr -> Ptr () -> Int32 -> Ptr () -> Word32 -> Ptr () -> Ptr () -> CInt -> 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 ()
-- NotificationMethod : WINBIO_ASYNC_NOTIFICATION_METHOD -> Int32
-- TargetWindow : HWND optional -> Ptr ()
-- MessageCode : DWORD optional -> Word32
-- CallbackRoutine : PWINBIO_ASYNC_COMPLETION_CALLBACK optional -> Ptr ()
-- UserData : void* optional -> Ptr ()
-- AsynchronousOpen : BOOL -> CInt
-- SessionHandle : DWORD* optional, out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let winbioasyncopensession =
  foreign "WinBioAsyncOpenSession"
    (uint32_t @-> uint32_t @-> uint32_t @-> (ptr uint32_t) @-> size_t @-> (ptr void) @-> int32_t @-> (ptr void) @-> uint32_t @-> (ptr void) @-> (ptr void) @-> int32_t @-> (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) *)
(* NotificationMethod : WINBIO_ASYNC_NOTIFICATION_METHOD -> int32_t *)
(* TargetWindow : HWND optional -> (ptr void) *)
(* MessageCode : DWORD optional -> uint32_t *)
(* CallbackRoutine : PWINBIO_ASYNC_COMPLETION_CALLBACK optional -> (ptr void) *)
(* UserData : void* optional -> (ptr void) *)
(* AsynchronousOpen : BOOL -> int32_t *)
(* SessionHandle : DWORD* optional, 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 ("WinBioAsyncOpenSession" win-bio-async-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
  (notification-method :int32)   ; WINBIO_ASYNC_NOTIFICATION_METHOD
  (target-window :pointer)   ; HWND optional
  (message-code :uint32)   ; DWORD optional
  (callback-routine :pointer)   ; PWINBIO_ASYNC_COMPLETION_CALLBACK optional
  (user-data :pointer)   ; void* optional
  (asynchronous-open :int32)   ; BOOL
  (session-handle :pointer))   ; DWORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WinBioAsyncOpenSession = Win32::API::More->new('winbio',
    'int WinBioAsyncOpenSession(DWORD Factor, DWORD PoolType, DWORD Flags, LPVOID UnitArray, WPARAM UnitCount, LPVOID DatabaseId, int NotificationMethod, HANDLE TargetWindow, DWORD MessageCode, LPVOID CallbackRoutine, LPVOID UserData, BOOL AsynchronousOpen, LPVOID SessionHandle)');
# my $ret = $WinBioAsyncOpenSession->Call($Factor, $PoolType, $Flags, $UnitArray, $UnitCount, $DatabaseId, $NotificationMethod, $TargetWindow, $MessageCode, $CallbackRoutine, $UserData, $AsynchronousOpen, $SessionHandle);
# Factor : DWORD -> DWORD
# PoolType : WINBIO_POOL -> DWORD
# Flags : DWORD -> DWORD
# UnitArray : DWORD* optional -> LPVOID
# UnitCount : UINT_PTR optional -> WPARAM
# DatabaseId : GUID* optional -> LPVOID
# NotificationMethod : WINBIO_ASYNC_NOTIFICATION_METHOD -> int
# TargetWindow : HWND optional -> HANDLE
# MessageCode : DWORD optional -> DWORD
# CallbackRoutine : PWINBIO_ASYNC_COMPLETION_CALLBACK optional -> LPVOID
# UserData : void* optional -> LPVOID
# AsynchronousOpen : BOOL -> BOOL
# SessionHandle : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

使用する型