ISCardDatabase::ListCards 方法

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

ListCards 方法检索与指定接口标识符匹配的所有智能卡名称, (GUID) 和/或指定的 ATR 字符串

语法

HRESULT ListCards(
  [in]  LPBYTEBUFFER pAtr,
  [in]  LPSAFEARRAY  pInterfaceGuids,
  [in]  LONG         localeId,
  [out] LPSAFEARRAY  *ppCardNames
);

parameters

pAtr [in]

指向智能卡 ATR 字符串的指针。 必须将 ATR 字符串打包到 IByteBuffer 中

pInterfaceGuids [in]

指向 COM 接口标识符的 SAFEARRAY 的指针, (以 BSTR 格式) GUID。

localeId [in]

语言本地化标识符。

ppCardNames [out]

指向 BSTR 的 SAFEARRAY 的指针,其中包含满足搜索参数(如果成功)的智能卡的名称;如果操作失败,则为 NULL

返回值

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

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

 

备注

若要检索所有已知的 读取器读取器,请分别调用 ListReadersListReaderGroups

若要检索主服务或特定卡分别卡 GetProviderCardIdListCardInterfaces

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

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

示例

以下示例演示如何检索与指定的 ATR 字符串匹配的智能卡名称。

// Define or determine byAtr as needed for your ATR use.
BYTE byAtr[] = {0x3b,0x27,0x00,0x80,0x65,0xa2,0x0c,0x01,0x01,0x37};
LPSAFEARRAY pSafeArray = NULL;
HRESULT          hr;

// pIByteBuff is a pointer to an instance of IByteBuffer.
hr = pIByteBuff->Initialize(sizeof(byAtr), byAtr);

// Call the function for the specified ATR.
hr = pISCDataBase->ListCards(pIByteBuff,
                             NULL,
                             0,
                             &pSafeArray);
if (FAILED(hr))
{
   printf("Failed ListCards\n");
   // Take other error handling action as needed.
}
else
{
   // Use the safe array as needed.
}

要求

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

另请参阅

GetProviderCardId

ISCardDatabase

ListCardInterfaces

ListReaderGroups

ListReaders