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

SCardIntroduceReaderGroupW

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

シグネチャ

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

INT SCardIntroduceReaderGroupW(
    UINT_PTR hContext,
    LPCWSTR szGroupName
);

パラメーター

名前方向
hContextUINT_PTRin
szGroupNameLPCWSTRin

戻り値の型: INT

各言語での呼び出し定義

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

INT SCardIntroduceReaderGroupW(
    UINT_PTR hContext,
    LPCWSTR szGroupName
);
[DllImport("WinSCard.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int SCardIntroduceReaderGroupW(
    UIntPtr hContext,   // UINT_PTR
    [MarshalAs(UnmanagedType.LPWStr)] string szGroupName   // LPCWSTR
);
<DllImport("WinSCard.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SCardIntroduceReaderGroupW(
    hContext As UIntPtr,   ' UINT_PTR
    <MarshalAs(UnmanagedType.LPWStr)> szGroupName As String   ' LPCWSTR
) As Integer
End Function
' hContext : UINT_PTR
' szGroupName : LPCWSTR
Declare PtrSafe Function SCardIntroduceReaderGroupW Lib "winscard" ( _
    ByVal hContext As LongPtr, _
    ByVal szGroupName As LongPtr) 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

SCardIntroduceReaderGroupW = ctypes.windll.winscard.SCardIntroduceReaderGroupW
SCardIntroduceReaderGroupW.restype = ctypes.c_int
SCardIntroduceReaderGroupW.argtypes = [
    ctypes.c_size_t,  # hContext : UINT_PTR
    wintypes.LPCWSTR,  # szGroupName : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	winscard = windows.NewLazySystemDLL("WinSCard.dll")
	procSCardIntroduceReaderGroupW = winscard.NewProc("SCardIntroduceReaderGroupW")
)

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