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

SCardGetDeviceTypeIdA

関数
指定したスマートカードリーダーのデバイスタイプIDを取得する(ANSI版)。
DLLWinSCard.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

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

INT SCardGetDeviceTypeIdA(
    UINT_PTR hContext,
    LPCSTR szReaderName,
    DWORD* pdwDeviceTypeId
);

パラメーター

名前方向
hContextUINT_PTRin
szReaderNameLPCSTRin
pdwDeviceTypeIdDWORD*inout

戻り値の型: INT

各言語での呼び出し定義

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

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

SCardGetDeviceTypeIdA = ctypes.windll.winscard.SCardGetDeviceTypeIdA
SCardGetDeviceTypeIdA.restype = ctypes.c_int
SCardGetDeviceTypeIdA.argtypes = [
    ctypes.c_size_t,  # hContext : UINT_PTR
    wintypes.LPCSTR,  # szReaderName : LPCSTR
    ctypes.POINTER(wintypes.DWORD),  # pdwDeviceTypeId : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WinSCard.dll')
SCardGetDeviceTypeIdA = Fiddle::Function.new(
  lib['SCardGetDeviceTypeIdA'],
  [
    Fiddle::TYPE_UINTPTR_T,  # hContext : UINT_PTR
    Fiddle::TYPE_VOIDP,  # szReaderName : LPCSTR
    Fiddle::TYPE_VOIDP,  # pdwDeviceTypeId : DWORD* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "winscard")]
extern "system" {
    fn SCardGetDeviceTypeIdA(
        hContext: usize,  // UINT_PTR
        szReaderName: *const u8,  // LPCSTR
        pdwDeviceTypeId: *mut u32  // DWORD* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WinSCard.dll", CharSet = CharSet.Ansi)]
public static extern int SCardGetDeviceTypeIdA(UIntPtr hContext, [MarshalAs(UnmanagedType.LPStr)] string szReaderName, ref uint pdwDeviceTypeId);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WinSCard_SCardGetDeviceTypeIdA' -Namespace Win32 -PassThru
# $api::SCardGetDeviceTypeIdA(hContext, szReaderName, pdwDeviceTypeId)
#uselib "WinSCard.dll"
#func global SCardGetDeviceTypeIdA "SCardGetDeviceTypeIdA" sptr, sptr, sptr
; SCardGetDeviceTypeIdA hContext, szReaderName, varptr(pdwDeviceTypeId)   ; 戻り値は stat
; hContext : UINT_PTR -> "sptr"
; szReaderName : LPCSTR -> "sptr"
; pdwDeviceTypeId : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WinSCard.dll"
#cfunc global SCardGetDeviceTypeIdA "SCardGetDeviceTypeIdA" sptr, str, var
; res = SCardGetDeviceTypeIdA(hContext, szReaderName, pdwDeviceTypeId)
; hContext : UINT_PTR -> "sptr"
; szReaderName : LPCSTR -> "str"
; pdwDeviceTypeId : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT SCardGetDeviceTypeIdA(UINT_PTR hContext, LPCSTR szReaderName, DWORD* pdwDeviceTypeId)
#uselib "WinSCard.dll"
#cfunc global SCardGetDeviceTypeIdA "SCardGetDeviceTypeIdA" intptr, str, var
; res = SCardGetDeviceTypeIdA(hContext, szReaderName, pdwDeviceTypeId)
; hContext : UINT_PTR -> "intptr"
; szReaderName : LPCSTR -> "str"
; pdwDeviceTypeId : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winscard = windows.NewLazySystemDLL("WinSCard.dll")
	procSCardGetDeviceTypeIdA = winscard.NewProc("SCardGetDeviceTypeIdA")
)

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