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

SCardListCardsA

関数
ATRやインターフェイスに一致するカード名を列挙する。
DLLWinSCard.dll文字セットANSI (-A)呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

INT SCardListCardsA(
    UINT_PTR hContext,
    BYTE* pbAtr,   // optional
    const GUID* rgquidInterfaces,   // optional
    DWORD cguidInterfaceCount,
    LPSTR mszCards,   // optional
    DWORD* pcchCards
);

パラメーター

名前方向
hContextUINT_PTRin
pbAtrBYTE*inoptional
rgquidInterfacesGUID*inoptional
cguidInterfaceCountDWORDin
mszCardsLPSTRoutoptional
pcchCardsDWORD*inout

戻り値の型: INT

各言語での呼び出し定義

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

INT SCardListCardsA(
    UINT_PTR hContext,
    BYTE* pbAtr,   // optional
    const GUID* rgquidInterfaces,   // optional
    DWORD cguidInterfaceCount,
    LPSTR mszCards,   // optional
    DWORD* pcchCards
);
[DllImport("WinSCard.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int SCardListCardsA(
    UIntPtr hContext,   // UINT_PTR
    IntPtr pbAtr,   // BYTE* optional
    IntPtr rgquidInterfaces,   // GUID* optional
    uint cguidInterfaceCount,   // DWORD
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder mszCards,   // LPSTR optional, out
    ref uint pcchCards   // DWORD* in/out
);
<DllImport("WinSCard.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SCardListCardsA(
    hContext As UIntPtr,   ' UINT_PTR
    pbAtr As IntPtr,   ' BYTE* optional
    rgquidInterfaces As IntPtr,   ' GUID* optional
    cguidInterfaceCount As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPStr)> mszCards As System.Text.StringBuilder,   ' LPSTR optional, out
    ByRef pcchCards As UInteger   ' DWORD* in/out
) As Integer
End Function
' hContext : UINT_PTR
' pbAtr : BYTE* optional
' rgquidInterfaces : GUID* optional
' cguidInterfaceCount : DWORD
' mszCards : LPSTR optional, out
' pcchCards : DWORD* in/out
Declare PtrSafe Function SCardListCardsA Lib "winscard" ( _
    ByVal hContext As LongPtr, _
    ByVal pbAtr As LongPtr, _
    ByVal rgquidInterfaces As LongPtr, _
    ByVal cguidInterfaceCount As Long, _
    ByVal mszCards As String, _
    ByRef pcchCards As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SCardListCardsA = ctypes.windll.winscard.SCardListCardsA
SCardListCardsA.restype = ctypes.c_int
SCardListCardsA.argtypes = [
    ctypes.c_size_t,  # hContext : UINT_PTR
    ctypes.POINTER(ctypes.c_ubyte),  # pbAtr : BYTE* optional
    ctypes.c_void_p,  # rgquidInterfaces : GUID* optional
    wintypes.DWORD,  # cguidInterfaceCount : DWORD
    wintypes.LPSTR,  # mszCards : LPSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcchCards : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WinSCard.dll')
SCardListCardsA = Fiddle::Function.new(
  lib['SCardListCardsA'],
  [
    Fiddle::TYPE_UINTPTR_T,  # hContext : UINT_PTR
    Fiddle::TYPE_VOIDP,  # pbAtr : BYTE* optional
    Fiddle::TYPE_VOIDP,  # rgquidInterfaces : GUID* optional
    -Fiddle::TYPE_INT,  # cguidInterfaceCount : DWORD
    Fiddle::TYPE_VOIDP,  # mszCards : LPSTR optional, out
    Fiddle::TYPE_VOIDP,  # pcchCards : DWORD* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "winscard")]
extern "system" {
    fn SCardListCardsA(
        hContext: usize,  // UINT_PTR
        pbAtr: *mut u8,  // BYTE* optional
        rgquidInterfaces: *const GUID,  // GUID* optional
        cguidInterfaceCount: u32,  // DWORD
        mszCards: *mut u8,  // LPSTR optional, out
        pcchCards: *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 SCardListCardsA(UIntPtr hContext, IntPtr pbAtr, IntPtr rgquidInterfaces, uint cguidInterfaceCount, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder mszCards, ref uint pcchCards);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WinSCard_SCardListCardsA' -Namespace Win32 -PassThru
# $api::SCardListCardsA(hContext, pbAtr, rgquidInterfaces, cguidInterfaceCount, mszCards, pcchCards)
#uselib "WinSCard.dll"
#func global SCardListCardsA "SCardListCardsA" sptr, sptr, sptr, sptr, sptr, sptr
; SCardListCardsA hContext, varptr(pbAtr), varptr(rgquidInterfaces), cguidInterfaceCount, varptr(mszCards), varptr(pcchCards)   ; 戻り値は stat
; hContext : UINT_PTR -> "sptr"
; pbAtr : BYTE* optional -> "sptr"
; rgquidInterfaces : GUID* optional -> "sptr"
; cguidInterfaceCount : DWORD -> "sptr"
; mszCards : LPSTR optional, out -> "sptr"
; pcchCards : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WinSCard.dll"
#cfunc global SCardListCardsA "SCardListCardsA" sptr, var, var, int, var, var
; res = SCardListCardsA(hContext, pbAtr, rgquidInterfaces, cguidInterfaceCount, mszCards, pcchCards)
; hContext : UINT_PTR -> "sptr"
; pbAtr : BYTE* optional -> "var"
; rgquidInterfaces : GUID* optional -> "var"
; cguidInterfaceCount : DWORD -> "int"
; mszCards : LPSTR optional, out -> "var"
; pcchCards : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT SCardListCardsA(UINT_PTR hContext, BYTE* pbAtr, GUID* rgquidInterfaces, DWORD cguidInterfaceCount, LPSTR mszCards, DWORD* pcchCards)
#uselib "WinSCard.dll"
#cfunc global SCardListCardsA "SCardListCardsA" intptr, var, var, int, var, var
; res = SCardListCardsA(hContext, pbAtr, rgquidInterfaces, cguidInterfaceCount, mszCards, pcchCards)
; hContext : UINT_PTR -> "intptr"
; pbAtr : BYTE* optional -> "var"
; rgquidInterfaces : GUID* optional -> "var"
; cguidInterfaceCount : DWORD -> "int"
; mszCards : LPSTR optional, out -> "var"
; pcchCards : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winscard = windows.NewLazySystemDLL("WinSCard.dll")
	procSCardListCardsA = winscard.NewProc("SCardListCardsA")
)

// hContext (UINT_PTR), pbAtr (BYTE* optional), rgquidInterfaces (GUID* optional), cguidInterfaceCount (DWORD), mszCards (LPSTR optional, out), pcchCards (DWORD* in/out)
r1, _, err := procSCardListCardsA.Call(
	uintptr(hContext),
	uintptr(pbAtr),
	uintptr(rgquidInterfaces),
	uintptr(cguidInterfaceCount),
	uintptr(mszCards),
	uintptr(pcchCards),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function SCardListCardsA(
  hContext: NativeUInt;   // UINT_PTR
  pbAtr: Pointer;   // BYTE* optional
  rgquidInterfaces: PGUID;   // GUID* optional
  cguidInterfaceCount: DWORD;   // DWORD
  mszCards: PAnsiChar;   // LPSTR optional, out
  pcchCards: Pointer   // DWORD* in/out
): Integer; stdcall;
  external 'WinSCard.dll' name 'SCardListCardsA';
result := DllCall("WinSCard\SCardListCardsA"
    , "UPtr", hContext   ; UINT_PTR
    , "Ptr", pbAtr   ; BYTE* optional
    , "Ptr", rgquidInterfaces   ; GUID* optional
    , "UInt", cguidInterfaceCount   ; DWORD
    , "Ptr", mszCards   ; LPSTR optional, out
    , "Ptr", pcchCards   ; DWORD* in/out
    , "Int")   ; return: INT
●SCardListCardsA(hContext, pbAtr, rgquidInterfaces, cguidInterfaceCount, mszCards, pcchCards) = DLL("WinSCard.dll", "int SCardListCardsA(int, void*, void*, dword, char*, void*)")
# 呼び出し: SCardListCardsA(hContext, pbAtr, rgquidInterfaces, cguidInterfaceCount, mszCards, pcchCards)
# hContext : UINT_PTR -> "int"
# pbAtr : BYTE* optional -> "void*"
# rgquidInterfaces : GUID* optional -> "void*"
# cguidInterfaceCount : DWORD -> "dword"
# mszCards : LPSTR optional, out -> "char*"
# pcchCards : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。