ISCardCmd::get_ApduReply 方法

[ get_ApduReply 方法可用于“要求”部分中指定的操作系统。 它不适用于 Windows Server 2003 Service Pack 1 (SP1) 及更高版本、Windows Vista、Windows Server 2008 和操作系统的后续版本。 智能卡模块提供类似的功能。]

get_ApduReply 方法检索回复 APDU,并将其置于特定的字节缓冲区中。 如果未对命令 APDU 执行任何事务,则回复可能为 NULL

语法

HRESULT get_ApduReply(
  [out] LPBYTEBUFFER *ppReplyApdu
);

parameters

ppReplyApdu [out]

指向字节缓冲区的指针 (通过包含返回时 APDU 回复消息的 IStream 对象) 映射。

返回值

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

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

 

备注

若要确定 APDU 回复的长度,请调用 get_ApduReplyLength

若要设置新的回复 APDU,请调用 put_ApduReply

有关此接口提供的所有方法的列表,请参阅 ISCardCmd

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

示例

以下示例演示如何检索回复数据。 该示例假定 lLe 是 LONG 类型的变量,其值是通过之前调用 ISCardCmd::get_ApduReplyLength 方法设置的,pIByteReply 是指向 IByteBuffer 接口实例的有效指针,pISCardCmd 是指向 ISCardCmd 接口实例的有效指针。

HRESULT      hr;

if (lLe > 0)
{
    // Get reply data if available.
    hr = pISCardCmd->get_ApduReply(&pIByteReply);
    if (FAILED(hr)) 
    {
        printf("Failed ISCardCmd::get_ApduReply.\n");
        // Take other error handling action as needed.
    }
    else
    {
        BYTE byReplyBytes[256];
        LONG lBytesRead;

        hr = pIByteReply->Read(byReplyBytes, lLe, &lBytesRead);
        if (FAILED(hr))
        {
            printf("Failed IByteBuffer::Read.\n");
            // Take other error handling action as needed.
        }
        // Use the bytes in byReplyBytes as needed.
    }
}

要求

要求
最低受支持的客户端
Windows XP [仅限桌面应用]
最低受支持的服务器
Windows Server 2003 [仅限桌面应用]
客户端支持终止
Windows XP
终止服务器支持
Windows Server 2003
标头
Scarddat.h
类型库
Scarddat.tlb
DLL
Scardssp.dll
IID
IID_ISCardCmd定义为 D5778AE3-43DE-11D0-9171-00AA00C18068

另请参阅

get_ApduReplyLength

ISCardCmd

put_ApduReply