EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.

SCardGetReaderDeviceInstanceId function

The SCardGetReaderDeviceInstanceId function gets the device instance identifier of the card reader for the given reader name. This function does not affect the state of the reader.

Syntax


LONG WINAPI SCardGetReaderDeviceInstanceId(
  _In_       SCARDCONTEXT hContext,
  _In_       LPCTSTR szReaderName,
  _Out_opt_  LPTSTR szDeviceInstanceId,
  _Inout_    LPDWORD cchDeviceInstanceId
);

Parameters

hContext [in]

Handle that identifies the resource manager context for the query. You can set the resource manager context by a previous call to the SCardEstablishContext function. This parameter cannot be NULL.

szReaderName [in]

Reader name. You can get this value by calling the SCardListReaders function.

szDeviceInstanceId [out, optional]

Buffer that receives the device instance ID of the reader. If this value is NULL, the function ignores the buffer length supplied in cchDeviceInstanceId parameter, writes the length of the buffer that would have been returned if this parameter had not been NULL to cchDeviceInstanceId, and returns a success code.

cchDeviceInstanceId [in, out]

Length, in characters, of the szDeviceInstanceId buffer, including the NULL terminator. If the buffer length is specified as SCARD_AUTOALLOCATE, then the szDeviceInstanceId parameter is converted to a pointer to a byte pointer, and receives the address of a block of memory containing the instance id. This block of memory must be deallocated with the SCardFreeMemory function.

Return value

This function returns different values depending on whether it succeeds or fails.

Return codeDescription
Success

SCARD_S_SUCCESS.

Failure

An error code. For more information, see Smart Card Return Values.

 

Remarks

This function is not redirected. Calling the SCardGetReaderDeviceInstanceId function when inside a Remote Desktop session fails with the SCARD_E_READER_UNAVAILABLE error code.

Examples



LONG     lReturn;
LPTSTR   szReaderName = "USB Smart Card Reader 0";
WCHAR    szDeviceInstanceId[256];
DWORD    cchDeviceInstanceId = 256;

// Retrieve the reader's device instance ID.
// hContext was set by a previous call to SCardEstablishContext.
lReturn = SCardGetReaderDeviceInstanceId (hContext,
                         szReaderName,
                         szDeviceInstanceId,
                         &cchDeviceInstanceId);

if ( SCARD_S_SUCCESS != lReturn )
{
    printf("Failed SCardGetReaderDeviceInstanceId - %x\n", lReturn);
    // Take appropriate action.
}




Requirements

Minimum supported client

Windows 8 [desktop apps only]

Minimum supported server

Windows Server 2012 [desktop apps only]

Header

Winscard.h

 

 

Ajouts de la communauté

AJOUTER
Afficher:
© 2014 Microsoft