SCardSetAttrib function (winscard.h)

The SCardSetAttrib function sets the given reader attribute for the given handle. It does not affect the state of the reader, reader driver, or smart card. Not all attributes are supported by all readers (nor can they be set at all times) as many of the attributes are under direct control of the transport protocol.

Syntax

LONG SCardSetAttrib(
  [in] SCARDHANDLE hCard,
  [in] DWORD       dwAttrId,
  [in] LPCBYTE     pbAttr,
  [in] DWORD       cbAttrLen
);

Parameters

[in] hCard

Reference value returned from SCardConnect.

[in] dwAttrId

Identifier for the attribute to set. The values are write-only. Note that vendors may not support all attributes.

Value Meaning
SCARD_ATTR_SUPRESS_T1_IFS_REQUEST
Suppress sending of T=1 IFSD packet from the reader to the card. (Can be used if the currently inserted card does not support an IFSD request.)

[in] pbAttr

Pointer to a buffer that supplies the attribute whose ID is supplied in dwAttrId.

[in] cbAttrLen

Length (in bytes) of the attribute value in the pbAttr buffer.

Return value

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

The SCardSetAttrib function is a direct card access function. For information about other direct access functions, see Direct Card Access Functions.

Examples

The following example shows how to set an attribute.

// Set the attribute.
// hCardHandle was set by a previous call to SCardConnect.
// dwAttrID is a DWORD value, specifying the attribute ID.
// pbAttr points to the buffer of the new value.
// cByte is the count of bytes in the buffer.
lReturn = SCardSetAttrib(hCardHandle,
                         dwAttrID,
                         (LPBYTE)pbAttr,
                         cByte);
if ( SCARD_S_SUCCESS != lReturn )
    printf("Failed SCardSetAttrib\n");

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header winscard.h
Library Winscard.lib
DLL Winscard.dll

See also

SCardConnect

SCardGetAttrib