SCardIntroduceReaderA 函数 (winscard.h)

SCardIntroduceReader 函数为现有智能卡读取器引入了新名称。

注意智能卡阅读器会自动引入系统;智能卡阅读器供应商的安装程序也可以将智能卡阅读器引入系统。
 

语法

LONG SCardIntroduceReaderA(
  [in] SCARDCONTEXT hContext,
  [in] LPCSTR       szReaderName,
  [in] LPCSTR       szDeviceName
);

参数

[in] hContext

标识 资源管理器上下文的句柄。 资源管理器上下文是由之前对 SCardEstablishContext 的调用设置的。 此参数不能为 NULL

[in] szReaderName

要分配给读取器的显示名称。

[in] szDeviceName

智能卡读取器的系统名称,例如“MyReader 01”。

返回值

此函数根据是成功还是失败返回不同的值。

返回代码 说明
Success
SCARD_S_SUCCESS。
失败
错误代码。 有关详细信息,请参阅 智能卡返回值

注解

系统上安装的所有读取器都会通过其系统名称自动引入。 通常,调用 SCardIntroduceReader 只是为了更改现有读取器的名称。

SCardIntroduceReader 函数是数据库管理功能。 有关其他数据库管理功能的详细信息,请参阅 智能卡数据库管理功能

若要删除读取器,请使用 SCardForgetReader

示例

以下示例演示如何引入智能卡读取器。

// This example renames the reader name.
// This is a two-step process (first add the new
// name, then forget the old name).
LPBYTE    pbAttr = NULL;
DWORD     cByte = SCARD_AUTOALLOCATE;
LONG      lReturn;

// Step 1: Add the new reader name.
// The device name attribute is a necessary value.
// hCardHandle was set by a previous call to SCardConnect.
lReturn = SCardGetAttrib(hCardHandle,
                         SCARD_ATTR_DEVICE_SYSTEM_NAME,
                         (LPBYTE)&pbAttr,
                         &cByte);
if ( SCARD_S_SUCCESS != lReturn )
{
    printf("Failed SCardGetAttrib\n");
    exit(1);  // Or other error action
}
// Add the reader name.
// hContext was set earlier by SCardEstablishContext.
lReturn = SCardIntroduceReader(hContext,
                               TEXT("My New Reader Name"),
                               (LPCTSTR)pbAttr );
if ( SCARD_S_SUCCESS != lReturn )
{
    printf("Failed SCardIntroduceReader\n");
    exit(1);  // Or other error action
}

// Step 2: Forget the old reader name.
lReturn = SCardForgetReader(hContext,
                            (LPCTSTR)pbAttr );
if ( SCARD_S_SUCCESS != lReturn )
{
    printf("Failed SCardForgetReader\n");
    exit(1);  // Or other error action
}

// Free the memory when done.
lReturn = SCardFreeMemory( hContext, pbAttr );

注意

winscard.h 标头将 SCardIntroduceReader 定义为别名,该别名根据 UNICODE 预处理器常量的定义自动选择此函数的 ANSI 或 Unicode 版本。 将非特定编码别名与非非特定编码的代码混合使用可能会导致不匹配,从而导致编译或运行时错误。 有关详细信息,请参阅 函数原型的约定

要求

要求
最低受支持的客户端 Windows XP [仅限桌面应用]
最低受支持的服务器 Windows Server 2003 [仅限桌面应用]
目标平台 Windows
标头 winscard.h
Library Winscard.lib
DLL Winscard.dll

另请参阅

SCardEstablishContext

SCardForgetReader

SCardIntroduceCardType

SCardIntroduceReaderGroup