CardEnumFiles function

The CardEnumFiles function returns name information about available files in a directory as a multistring list.


  _In_     PCARD_DATA pCardData,
  _In_opt_ LPSTR      pszDirectoryName,
  _Out_    LPSTR      *pmszFileNames,
  _Out_    LPDWORD    pdwcbFileName,
  _In_     DWORD      dwFlags


pCardData [in]

Context information for the call. For more information, see CardAcquireContext.

pszDirectoryName [in, optional]

Name of the directory. Set to NULL for root.

pmszFileNames [out]

Pointer to byte pointer to receive returned multistring. Names of files in the named directory or for the root directory if the directory name passed in was NULL. If the directory does not contain files, the SCARD_E_FILE_NOT_FOUND error code should be returned.

pdwcbFileName [out]

Size of allocation pointed to by pmszFileNames.

dwFlags [in]

Reserved. Set to 0.

Return value

Zero on success; otherwise, nonzero.


CardEnumFiles should check the dwFlags value to ensure that it is zero. If not, it should return SCARD_E_INVALID_PARAMETER.

The multistring is allocated by the card minidriver and must be freed by the caller by using PFN_CSP_FREE. It is returned as a contiguous buffer and must require exactly one call to free. The format of this string is a multistring. It is a contiguous block of data. Individual strings are separated by “\0” characters. The block is terminated by two “\0” characters in a row (one for the final string and another to indicate that the multistring is finished).

If CardEnumFiles is called on a nonexistent directory, an SCARD_E_DIR_NOT_FOUND error code must be returned.

If the name that pszDirectoryName specified is longer than the maximum length for file/directory names, SCARD_E_INVALID_PARAMETER must be returned.


Target platform



Cardmod.h (include Cardmod.h)



Send comments about this topic to Microsoft