ISCardISO7816::WriteRecord

The WriteRecord method constructs an APDU command that initiates one of the following operations:

When no indication is given in the data coding byte, the logical OR behavior applies.

Note When using current record addressing, the command sets the record pointer on the successfully updated record.

HRESULT WriteRecord(
  BYTE byRecordId,
  BYTE byRefCtrl,
  LPBYTEBUFFER pData,
  LPSCARDCMD *ppCmd
);
 

Parameters

byRecordId [in, defaultvalue(NULL_BYTE)]
Record identification. This is the P1 value:

P1 = '00' designates the current record.

P1 != '00' is the number of the specified record.

byRefCtrl [in, defaultvalue(NULL_BYTE)]
Coding of the reference control P2:
Meaning 8 7 6 5 4 3 2 1
Current EF 0 0 0 0 0 - - -
Short EF ID x x x x x - - -
First Record - - - - - 0 0 0
Last Record - - - - - 0 0 1
Next Record - - - - - 0 1 0
Previous Record - - - - - 0 1 1
Record # in P1 - - - - - 1 0 0

pData [in]
Pointer to the record to be written.
ppCmd [in, out]
On input, a pointer to an ISCardCmd interface object or NULL.

On return, it is filled with the APDU command constructed by this operation. If ppCmd was set to NULL, a smart card ISCardCmd object is internally created and returned via the ppCmd pointer.

Return Values

The possible return values are the following:

Value Meaning
S_OK Operation completed successfully.
E_INVALIDARG Invalid parameter.
E_POINTER A bad pointer was passed in.
E_OUTOFMEMORY Out of memory.

Remarks

The encapsulated command can only be performed if the security status of the smart card satisfies the security attributes of the elementary file being processed.

When the command contains a valid short elementary identifier, it sets the file as current elementary file. If another elementary file is currently selected at the time of issuing this command, this command may be processed without identification of the currently selected file.

If the encapsulated command applies to a linear-fixed or cyclic-structured elementary file, it will abort if the record length is different from the length of the existing record. If it applies to a linear-variable structured elementary file, it may be carried out when the record length is different from the length of the existing record.

If P2=xxxxx011 and the elementary file is cyclic file, this command has the same behavior a command constructed using AppendRecord.

Elementary files without a record structure cannot be written to. The constructed command aborts if applied to an elementary file without a record structure.

For a list of all the methods provided by the ISCardISO7816 interface, see ISCardISO7816.

In addition to the COM error codes listed above, this interface may return a smart card error code if a smart card function was called to complete the request. For information on smart card error codes, see Error Codes.

QuickInfo

  Windows NT: Use version 4.0 SP3 and later.
  Windows: Use Windows 95 OSR2.1.
  Windows CE: Unsupported.
  Header: Declared in scardsrv.h.
  Import Library: scardsrv.tlb.

See Also

AppendRecord, ISCardISO7816, ReadRecord, UpdateRecord