ISCardISO7816::WriteBinary

The WriteBinary method constructs an APDU command that writes binary values into an elementary file.

Depending upon the file attributes, the command performs one of the following operations:

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

HRESULT WriteBinary(
  BYTE byP1,
  BYTE byP2,
  LPBYTEBUFFER pData,
  LPSCARDCMD *ppCmd
);
 

Parameters

byP1, byP2 [in]
Offset to the write location from the beginning of the binary file (EF).

If b8=1 in P1, then b7 and b6 of P1 are set to 0 (RFU bits), b5 to b1 of P1 are a short EF identifier and P2 is the offset of the first byte to be written in data units from the beginning of the file.

If b8=0 in P1, then P1||P2 is the offset of the first byte to be written in data units from the beginning of the file.

pData [in]
Pointer to the string of data units 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.

Once a write binary operation has been applied to a data unit of a one-time write EF, any further write operation referring to this data unit will be aborted if the content of the data unit or the logical erased state indicator (if any) attached to this data unit is different from the logical erased state.

Elementary files without a transparent structure cannot be written to. The encapsulated command aborts if applied to an elementary file without a transparent 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

EraseBinary, ISCardISO7816, ReadBinary, UpdateBinary