Skip to content

Latest commit

 

History

History
144 lines (109 loc) · 4.76 KB

nf-winscard-scardgetreaderdeviceinstanceida.md

File metadata and controls

144 lines (109 loc) · 4.76 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:winscard.SCardGetReaderDeviceInstanceIdA
SCardGetReaderDeviceInstanceIdA function (winscard.h)
Gets the device instance identifier of the card reader for the given reader name. This function does not affect the state of the reader. (ANSI)
SCardGetReaderDeviceInstanceIdA
security\scardgetreaderdeviceinstanceid.htm
security
306F1EAF-35A7-4449-802F-709667764737
12/05/2018
SCardGetReaderDeviceInstanceId, SCardGetReaderDeviceInstanceId function [Security], SCardGetReaderDeviceInstanceIdA, SCardGetReaderDeviceInstanceIdW, security.scardgetreaderdeviceinstanceid, winscard/SCardGetReaderDeviceInstanceId
winscard.h
Windows
Windows 8 [desktop apps only]
Windows Server 2012 [desktop apps only]
Windows
19H1
SCardGetReaderDeviceInstanceIdA
winscard/SCardGetReaderDeviceInstanceIdA
c++
APIRef
kbSyntax
HeaderDef
Winscard.h
SCardGetReaderDeviceInstanceId

SCardGetReaderDeviceInstanceIdA function

-description

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.

-parameters

-param 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.

-param szReaderName [in]

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

-param 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.

-param pcchDeviceInstanceId [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.

-returns

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

Return code Description
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.
}


Note

The winscard.h header defines SCardGetReaderDeviceInstanceId as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.