Win32 API 日本語リファレンス
ホームSecurity.Credentials › SCardIntroduceReaderA

SCardIntroduceReaderA

関数
新しいスマートカードリーダーをシステムに登録する。
DLLWinSCard.dll文字セットANSI (-A)呼出規約winapi対応OSWindows XP 以降

シグネチャ

// WinSCard.dll  (ANSI / -A)
#include <windows.h>

INT SCardIntroduceReaderA(
    UINT_PTR hContext,
    LPCSTR szReaderName,
    LPCSTR szDeviceName
);

パラメーター

名前方向
hContextUINT_PTRin
szReaderNameLPCSTRin
szDeviceNameLPCSTRin

戻り値の型: INT

各言語での呼び出し定義

// WinSCard.dll  (ANSI / -A)
#include <windows.h>

INT SCardIntroduceReaderA(
    UINT_PTR hContext,
    LPCSTR szReaderName,
    LPCSTR szDeviceName
);
[DllImport("WinSCard.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int SCardIntroduceReaderA(
    UIntPtr hContext,   // UINT_PTR
    [MarshalAs(UnmanagedType.LPStr)] string szReaderName,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string szDeviceName   // LPCSTR
);
<DllImport("WinSCard.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SCardIntroduceReaderA(
    hContext As UIntPtr,   ' UINT_PTR
    <MarshalAs(UnmanagedType.LPStr)> szReaderName As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> szDeviceName As String   ' LPCSTR
) As Integer
End Function
' hContext : UINT_PTR
' szReaderName : LPCSTR
' szDeviceName : LPCSTR
Declare PtrSafe Function SCardIntroduceReaderA Lib "winscard" ( _
    ByVal hContext As LongPtr, _
    ByVal szReaderName As String, _
    ByVal szDeviceName As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SCardIntroduceReaderA = ctypes.windll.winscard.SCardIntroduceReaderA
SCardIntroduceReaderA.restype = ctypes.c_int
SCardIntroduceReaderA.argtypes = [
    ctypes.c_size_t,  # hContext : UINT_PTR
    wintypes.LPCSTR,  # szReaderName : LPCSTR
    wintypes.LPCSTR,  # szDeviceName : LPCSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WinSCard.dll')
SCardIntroduceReaderA = Fiddle::Function.new(
  lib['SCardIntroduceReaderA'],
  [
    Fiddle::TYPE_UINTPTR_T,  # hContext : UINT_PTR
    Fiddle::TYPE_VOIDP,  # szReaderName : LPCSTR
    Fiddle::TYPE_VOIDP,  # szDeviceName : LPCSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "winscard")]
extern "system" {
    fn SCardIntroduceReaderA(
        hContext: usize,  // UINT_PTR
        szReaderName: *const u8,  // LPCSTR
        szDeviceName: *const u8  // LPCSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WinSCard.dll", CharSet = CharSet.Ansi)]
public static extern int SCardIntroduceReaderA(UIntPtr hContext, [MarshalAs(UnmanagedType.LPStr)] string szReaderName, [MarshalAs(UnmanagedType.LPStr)] string szDeviceName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WinSCard_SCardIntroduceReaderA' -Namespace Win32 -PassThru
# $api::SCardIntroduceReaderA(hContext, szReaderName, szDeviceName)
#uselib "WinSCard.dll"
#func global SCardIntroduceReaderA "SCardIntroduceReaderA" sptr, sptr, sptr
; SCardIntroduceReaderA hContext, szReaderName, szDeviceName   ; 戻り値は stat
; hContext : UINT_PTR -> "sptr"
; szReaderName : LPCSTR -> "sptr"
; szDeviceName : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WinSCard.dll"
#cfunc global SCardIntroduceReaderA "SCardIntroduceReaderA" sptr, str, str
; res = SCardIntroduceReaderA(hContext, szReaderName, szDeviceName)
; hContext : UINT_PTR -> "sptr"
; szReaderName : LPCSTR -> "str"
; szDeviceName : LPCSTR -> "str"
; INT SCardIntroduceReaderA(UINT_PTR hContext, LPCSTR szReaderName, LPCSTR szDeviceName)
#uselib "WinSCard.dll"
#cfunc global SCardIntroduceReaderA "SCardIntroduceReaderA" intptr, str, str
; res = SCardIntroduceReaderA(hContext, szReaderName, szDeviceName)
; hContext : UINT_PTR -> "intptr"
; szReaderName : LPCSTR -> "str"
; szDeviceName : LPCSTR -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winscard = windows.NewLazySystemDLL("WinSCard.dll")
	procSCardIntroduceReaderA = winscard.NewProc("SCardIntroduceReaderA")
)

// hContext (UINT_PTR), szReaderName (LPCSTR), szDeviceName (LPCSTR)
r1, _, err := procSCardIntroduceReaderA.Call(
	uintptr(hContext),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szReaderName))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szDeviceName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function SCardIntroduceReaderA(
  hContext: NativeUInt;   // UINT_PTR
  szReaderName: PAnsiChar;   // LPCSTR
  szDeviceName: PAnsiChar   // LPCSTR
): Integer; stdcall;
  external 'WinSCard.dll' name 'SCardIntroduceReaderA';
result := DllCall("WinSCard\SCardIntroduceReaderA"
    , "UPtr", hContext   ; UINT_PTR
    , "AStr", szReaderName   ; LPCSTR
    , "AStr", szDeviceName   ; LPCSTR
    , "Int")   ; return: INT
●SCardIntroduceReaderA(hContext, szReaderName, szDeviceName) = DLL("WinSCard.dll", "int SCardIntroduceReaderA(int, char*, char*)")
# 呼び出し: SCardIntroduceReaderA(hContext, szReaderName, szDeviceName)
# hContext : UINT_PTR -> "int"
# szReaderName : LPCSTR -> "char*"
# szDeviceName : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。