ISCardISO7816::SelectFile

The SelectFile method constructs an APDU command that sets a current elementary file within a logical channel. Subsequent commands may implicitly refer to the current file through the logical channel.

Selecting a directory (DF) within the card filestore — which may be the root (MF) of the filestore — makes it the current DF. After such a selection, an implicit current elementary file may be referred to through that logical channel.

Selecting an elementary file sets the selected file and its parent as current files.

After the answer to reset, the MF is implicitly selected through the basic logical channel, unless specified differently in the historical bytes or in the initial data string.

HRESULT SelectFile(
  BYTE byP1,
  BYTE byP2,
  LPBYTEBUFFER pData,
  LONG lBytesToRead,
  LPSCARDCMD *ppCmd
);
 

Parameters

byP1, byP2 [in]
Selection control.

P1 (upper byte in word):
Meaning 8 7 6 5 4 3 2 1
Select File ID 0 0 0 0 0 0 x x
EF, DF, or MF 0 0 0 0 0 0 0 0
child DF 0 0 0 0 0 0 0 1
EF under DF 0 0 0 0 0 0 1 0
parent DF of current DF 0 0 0 0 0 0 1 1

Meaning 8 7 6 5 4 3 2 1
Select by DF Name 0 0 0 0 0 1 x x
DFname 0 0 0 0 0 1 0 0
RFU 0 0 0 0 0 1 0 1
RFU 0 0 0 0 0 1 1 0
RFU 0 0 0 0 0 1 1 1

Meaning 8 7 6 5 4 3 2 1
Select by path 0 0 0 0 1 0 x x
from MF 0 0 0 0 1 0 0 0
current DF 0 0 0 0 1 0 0 1
RFU 0 0 0 0 1 0 1 0
RFU 0 0 0 0 1 0 1 1

When P1=00, the card knows either because of a specific coding of the file ID or because of the context of execution of the command if the file to select is the MF, a DF, or an EF.

When P1-P2=0000, if a file ID is provided, then it shall be unique in the following environments:

If P1-P2=0000 and if the data field is empty or equal to 3F00, then select the MF.

When P1=04, the data field is a DF name, possibly right truncated.

When supported, successive such commands with the same data field shall select DFs whose names match with the data field (that is, start with the command data field). If the card accepts the command with an empty data field, then all or a subset of the DFs can be successively selected.

P2 (lower byte of word):
Meaning 8 7 6 5 4 3 2 1
First occur 0 0 0 0 - - 0 0
Last occur 0 0 0 0 - - 0 1
Next occur 0 0 0 0 - - 1 0
Previous occur 0 0 0 0 - - 1 1

Meaning 8 7 6 5 4 3 2 1
File Control 0 0 0 0 x x - -
Return FCI 0 0 0 0 0 0 - -
Return FCP 0 0 0 0 0 1 - -
Return FMD 0 0 0 0 1 0 - -

pData [in, defaultvalue(NULL)]
Data for operation if needed; else, NULL. Types of data that are passed in this parameter include:
lBytesToRead [in, defaultvalue(0)]
Empty (that is, 0) or maximum length of data expected in response.
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

Unless otherwise specified, the correct execution of the encapsulated command modifies the security status according to the following rules:

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

ISCardISO7816