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

WinBioSetCredential

関数
指定種別の生体認証資格情報を設定する。
DLLwinbio.dll呼出規約winapi対応OSWindows 8.1 以降

シグネチャ

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

HRESULT WinBioSetCredential(
    WINBIO_CREDENTIAL_TYPE Type,
    BYTE* Credential,
    UINT_PTR CredentialSize,
    WINBIO_CREDENTIAL_FORMAT Format
);

パラメーター

名前方向説明
TypeWINBIO_CREDENTIAL_TYPEin設定する資格情報の種類(パスワード等)を指定する列挙値。
CredentialBYTE*in資格情報の生データバイト列へのポインタ。
CredentialSizeUINT_PTRinCredentialのバイトサイズ。
FormatWINBIO_CREDENTIAL_FORMATin資格情報のフォーマット(暗号化/平文等)を指定する列挙値。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WinBioSetCredential(
    WINBIO_CREDENTIAL_TYPE Type,
    BYTE* Credential,
    UINT_PTR CredentialSize,
    WINBIO_CREDENTIAL_FORMAT Format
);
[DllImport("winbio.dll", ExactSpelling = true)]
static extern int WinBioSetCredential(
    int Type,   // WINBIO_CREDENTIAL_TYPE
    IntPtr Credential,   // BYTE*
    UIntPtr CredentialSize,   // UINT_PTR
    int Format   // WINBIO_CREDENTIAL_FORMAT
);
<DllImport("winbio.dll", ExactSpelling:=True)>
Public Shared Function WinBioSetCredential(
    Type As Integer,   ' WINBIO_CREDENTIAL_TYPE
    Credential As IntPtr,   ' BYTE*
    CredentialSize As UIntPtr,   ' UINT_PTR
    Format As Integer   ' WINBIO_CREDENTIAL_FORMAT
) As Integer
End Function
' Type : WINBIO_CREDENTIAL_TYPE
' Credential : BYTE*
' CredentialSize : UINT_PTR
' Format : WINBIO_CREDENTIAL_FORMAT
Declare PtrSafe Function WinBioSetCredential Lib "winbio" ( _
    ByVal Type As Long, _
    ByVal Credential As LongPtr, _
    ByVal CredentialSize As LongPtr, _
    ByVal Format As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WinBioSetCredential = ctypes.windll.winbio.WinBioSetCredential
WinBioSetCredential.restype = ctypes.c_int
WinBioSetCredential.argtypes = [
    ctypes.c_int,  # Type : WINBIO_CREDENTIAL_TYPE
    ctypes.POINTER(ctypes.c_ubyte),  # Credential : BYTE*
    ctypes.c_size_t,  # CredentialSize : UINT_PTR
    ctypes.c_int,  # Format : WINBIO_CREDENTIAL_FORMAT
]
require 'fiddle'
require 'fiddle/import'

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

var (
	winbio = windows.NewLazySystemDLL("winbio.dll")
	procWinBioSetCredential = winbio.NewProc("WinBioSetCredential")
)

// Type (WINBIO_CREDENTIAL_TYPE), Credential (BYTE*), CredentialSize (UINT_PTR), Format (WINBIO_CREDENTIAL_FORMAT)
r1, _, err := procWinBioSetCredential.Call(
	uintptr(Type),
	uintptr(Credential),
	uintptr(CredentialSize),
	uintptr(Format),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WinBioSetCredential(
  Type: Integer;   // WINBIO_CREDENTIAL_TYPE
  Credential: Pointer;   // BYTE*
  CredentialSize: NativeUInt;   // UINT_PTR
  Format: Integer   // WINBIO_CREDENTIAL_FORMAT
): Integer; stdcall;
  external 'winbio.dll' name 'WinBioSetCredential';
result := DllCall("winbio\WinBioSetCredential"
    , "Int", Type   ; WINBIO_CREDENTIAL_TYPE
    , "Ptr", Credential   ; BYTE*
    , "UPtr", CredentialSize   ; UINT_PTR
    , "Int", Format   ; WINBIO_CREDENTIAL_FORMAT
    , "Int")   ; return: HRESULT
●WinBioSetCredential(Type, Credential, CredentialSize, Format) = DLL("winbio.dll", "int WinBioSetCredential(int, void*, int, int)")
# 呼び出し: WinBioSetCredential(Type, Credential, CredentialSize, Format)
# Type : WINBIO_CREDENTIAL_TYPE -> "int"
# Credential : BYTE* -> "void*"
# CredentialSize : UINT_PTR -> "int"
# Format : WINBIO_CREDENTIAL_FORMAT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef WinBioSetCredentialNative = Int32 Function(Int32, Pointer<Uint8>, UintPtr, Int32);
typedef WinBioSetCredentialDart = int Function(int, Pointer<Uint8>, int, int);
final WinBioSetCredential = DynamicLibrary.open('winbio.dll')
    .lookupFunction<WinBioSetCredentialNative, WinBioSetCredentialDart>('WinBioSetCredential');
// Type : WINBIO_CREDENTIAL_TYPE -> Int32
// Credential : BYTE* -> Pointer<Uint8>
// CredentialSize : UINT_PTR -> UintPtr
// Format : WINBIO_CREDENTIAL_FORMAT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WinBioSetCredential(
  Type: Integer;   // WINBIO_CREDENTIAL_TYPE
  Credential: Pointer;   // BYTE*
  CredentialSize: NativeUInt;   // UINT_PTR
  Format: Integer   // WINBIO_CREDENTIAL_FORMAT
): Integer; stdcall;
  external 'winbio.dll' name 'WinBioSetCredential';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WinBioSetCredential"
  c_WinBioSetCredential :: Int32 -> Ptr Word8 -> CUIntPtr -> Int32 -> IO Int32
-- Type : WINBIO_CREDENTIAL_TYPE -> Int32
-- Credential : BYTE* -> Ptr Word8
-- CredentialSize : UINT_PTR -> CUIntPtr
-- Format : WINBIO_CREDENTIAL_FORMAT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let winbiosetcredential =
  foreign "WinBioSetCredential"
    (int32_t @-> (ptr uint8_t) @-> size_t @-> int32_t @-> returning int32_t)
(* Type : WINBIO_CREDENTIAL_TYPE -> int32_t *)
(* Credential : BYTE* -> (ptr uint8_t) *)
(* CredentialSize : UINT_PTR -> size_t *)
(* Format : WINBIO_CREDENTIAL_FORMAT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library winbio (t "winbio.dll"))
(cffi:use-foreign-library winbio)

(cffi:defcfun ("WinBioSetCredential" win-bio-set-credential :convention :stdcall) :int32
  (type :int32)   ; WINBIO_CREDENTIAL_TYPE
  (credential :pointer)   ; BYTE*
  (credential-size :uint64)   ; UINT_PTR
  (format :int32))   ; WINBIO_CREDENTIAL_FORMAT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WinBioSetCredential = Win32::API::More->new('winbio',
    'int WinBioSetCredential(int Type, LPVOID Credential, WPARAM CredentialSize, int Format)');
# my $ret = $WinBioSetCredential->Call($Type, $Credential, $CredentialSize, $Format);
# Type : WINBIO_CREDENTIAL_TYPE -> int
# Credential : BYTE* -> LPVOID
# CredentialSize : UINT_PTR -> WPARAM
# Format : WINBIO_CREDENTIAL_FORMAT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型