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”。
傳回值
此函式會傳回不同的值,視其成功或失敗而定。
傳回碼 | Description |
---|---|
|
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 |
程式庫 | Winscard.lib |
Dll | Winscard.dll |
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應