ISCard::get_Atr 方法

[ get_Atr 方法可用于“要求”部分中指定的操作系统。 智能卡模块提供类似的功能。]

get_Atr 方法检索智能卡ATR 字符串

语法

HRESULT get_Atr(
  [out] LPBYTEBUFFER *ppAtr
);

parameters

ppAtr [out]

指向 IStream 形式的字节缓冲区的指针,该缓冲区将在返回时包含 ATR 字符串。

返回值

方法返回以下可能值之一。

返回代码 说明
S_OK
操作已成功完成。
E_INVALIDARG
ppAtr 参数无效。
E_POINTER
在 ppAtr 中传递了错误的指针。
E_OUTOFMEMORY
满足请求的内存不可用。

 

备注

除了上面列出的 COM 错误代码之外,如果调用智能卡函数来完成请求,则此接口可能返回智能卡错误代码。 有关详细信息,请参阅 智能卡返回值

示例

以下示例演示如何从智能卡检索 ATR 字符串。

// Retrieve the ATR.
// pISCard is a pointer to a previously instantiated ISCard.
// pAtr is a pointer to a previously instantiated IByteBuffer.
hr = pISCard->get_Atr(&pAtr);
if (FAILED(hr))
{
    printf("Failed get_Atr\n");
    // Take other error handling action.
}
// Success, you can now use IByteBuffer::Read to access ATR bytes.
BYTE  byAtr[32];
   long  lBytesRead, i;
   // Read the ATR string into a byte array.
   hr = pAtr->Read(byAtr, 32, &lBytesRead);
   // Use the ATR value. (This example merely displays the bytes.)
   for ( i = 0; i < lBytesRead; i++)
       printf("%c", *(byAtr + i));
   printf("\n");

要求

要求
最低受支持的客户端
Windows XP [仅限桌面应用]
最低受支持的服务器
Windows Server 2003 [仅限桌面应用]
终止客户端支持
Windows XP
终止服务器支持
Windows Server 2003
标头
Scardmgr.h
类型库
Scardmgr.tlb
DLL
Scardssp.dll
IID
IID_ISCard定义为 1461AAC3-6810-11D0-918F-00AA00C18068

另请参阅

get_CardHandle

get_Context

get_Protocol

get_Status

ISCard

IByteBuffer::Read