Funzione SCardIntroduceReaderA (winscard.h)

La funzione SCardIntroduceReader introduce un nuovo nome per un lettore di smart card esistente.

Nota I lettori di smart card vengono introdotti automaticamente nel sistema; Il programma di installazione di un fornitore di smart card reader può anche introdurre un lettore di smart card al sistema.
 

Sintassi

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

Parametri

[in] hContext

Handle che identifica il contesto di Resource Manager. Il contesto di Resource Manager viene impostato da una chiamata precedente a SCardEstablishContext. Questo parametro non può essere NULL.

[in] szReaderName

Nome visualizzato da assegnare al lettore.

[in] szDeviceName

Nome di sistema del lettore di smart card, ad esempio "MyReader 01".

Valore restituito

Questa funzione restituisce valori diversi a seconda che abbia esito positivo o negativo.

Codice restituito Descrizione
Success
SCARD_S_SUCCESS.
Operazioni non riuscite
Codice di errore. Per altre informazioni, vedere Valori restituiti della smart card.

Commenti

Tutti i lettori installati nel sistema vengono introdotti automaticamente dal nome del sistema. In genere, SCardIntroduceReader viene chiamato solo per modificare il nome di un lettore esistente.

La funzione SCardIntroduceReader è una funzione di gestione del database. Per altre informazioni su altre funzioni di gestione del database, vedere Funzioni di gestione del database smart card.

Per rimuovere un lettore, usare SCardForgetReader.

Esempio

L'esempio seguente illustra l'introduzione di un lettore di smart card.

// 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 );

Nota

L'intestazione winscard.h definisce SCardIntroduceReader come alias che seleziona automaticamente la versione ANSI o Unicode di questa funzione in base alla definizione della costante del preprocessore UNICODE. La combinazione dell'utilizzo dell'alias indipendente dalla codifica con il codice che non è indipendente dalla codifica può causare mancate corrispondenze che generano errori di compilazione o di runtime. Per altre informazioni, vedere Convenzioni per i prototipi di funzioni.

Requisiti

Requisito Valore
Client minimo supportato Windows XP [solo app desktop]
Server minimo supportato Windows Server 2003 [solo app desktop]
Piattaforma di destinazione Windows
Intestazione winscard.h
Libreria Winscard.lib
DLL Winscard.dll

Vedi anche

SCardEstablishContext

SCardForgetReader

SCardIntroduceCardType

SCardIntroduceReaderGroup