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

SCardGetDeviceTypeIdW

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

シグネチャ

// WinSCard.dll  (Unicode / -W)
#include <windows.h>

INT SCardGetDeviceTypeIdW(
    UINT_PTR hContext,
    LPCWSTR szReaderName,
    DWORD* pdwDeviceTypeId
);

パラメーター

名前方向
hContextUINT_PTRin
szReaderNameLPCWSTRin
pdwDeviceTypeIdDWORD*inout

戻り値の型: INT

各言語での呼び出し定義

// WinSCard.dll  (Unicode / -W)
#include <windows.h>

INT SCardGetDeviceTypeIdW(
    UINT_PTR hContext,
    LPCWSTR szReaderName,
    DWORD* pdwDeviceTypeId
);
[DllImport("WinSCard.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int SCardGetDeviceTypeIdW(
    UIntPtr hContext,   // UINT_PTR
    [MarshalAs(UnmanagedType.LPWStr)] string szReaderName,   // LPCWSTR
    ref uint pdwDeviceTypeId   // DWORD* in/out
);
<DllImport("WinSCard.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SCardGetDeviceTypeIdW(
    hContext As UIntPtr,   ' UINT_PTR
    <MarshalAs(UnmanagedType.LPWStr)> szReaderName As String,   ' LPCWSTR
    ByRef pdwDeviceTypeId As UInteger   ' DWORD* in/out
) As Integer
End Function
' hContext : UINT_PTR
' szReaderName : LPCWSTR
' pdwDeviceTypeId : DWORD* in/out
Declare PtrSafe Function SCardGetDeviceTypeIdW Lib "winscard" ( _
    ByVal hContext As LongPtr, _
    ByVal szReaderName As LongPtr, _
    ByRef pdwDeviceTypeId As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

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

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

var (
	winscard = windows.NewLazySystemDLL("WinSCard.dll")
	procSCardGetDeviceTypeIdW = winscard.NewProc("SCardGetDeviceTypeIdW")
)

// hContext (UINT_PTR), szReaderName (LPCWSTR), pdwDeviceTypeId (DWORD* in/out)
r1, _, err := procSCardGetDeviceTypeIdW.Call(
	uintptr(hContext),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szReaderName))),
	uintptr(pdwDeviceTypeId),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function SCardGetDeviceTypeIdW(
  hContext: NativeUInt;   // UINT_PTR
  szReaderName: PWideChar;   // LPCWSTR
  pdwDeviceTypeId: Pointer   // DWORD* in/out
): Integer; stdcall;
  external 'WinSCard.dll' name 'SCardGetDeviceTypeIdW';
result := DllCall("WinSCard\SCardGetDeviceTypeIdW"
    , "UPtr", hContext   ; UINT_PTR
    , "WStr", szReaderName   ; LPCWSTR
    , "Ptr", pdwDeviceTypeId   ; DWORD* in/out
    , "Int")   ; return: INT
●SCardGetDeviceTypeIdW(hContext, szReaderName, pdwDeviceTypeId) = DLL("WinSCard.dll", "int SCardGetDeviceTypeIdW(int, char*, void*)")
# 呼び出し: SCardGetDeviceTypeIdW(hContext, szReaderName, pdwDeviceTypeId)
# hContext : UINT_PTR -> "int"
# szReaderName : LPCWSTR -> "char*"
# pdwDeviceTypeId : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。