CardWriteFile Function

The CardWriteFile function, defined by a smart card module, writes data in a buffer to a file on a smart card. This function overwrites any data currently in the file.

Syntax

DWORD WINAPI CardWriteFile(
  __in  PCARD_DATA pCardData,
  __in  LPSTR pszDirectoryName,
  __in  LPSTR pszFileName,
  __in  DWORD dwFlags,
  __in  PBYTE pbData,
  __in  DWORD cbData
);

Parameters

  • pCardData [in]
    A pointer to a CARD_DATA structure received from a call to the CardAcquireContext function.

  • pszDirectoryName [in]
    A pointer to a null-terminated string that contains the name of the directory that contains the file to which to write. The function fails if the specified directory does not exist.

  • pszFileName [in]
    A pointer to a null-terminated string that contains the name of the file to which to write. The function fails if the specified file does not exist.

  • dwFlags [in]
    Reserved. This parameter must be set to zero.

  • pbData [in]
    A pointer to a buffer that contains the data to be written to the file.

  • cbData [in]
    The size, in bytes, of the pbData buffer.

Return Value

If the function succeeds, the function returns zero.

If the function fails, it returns a nonzero error value or one of the following possible error values.

Return code/value Description
SCARD_E_FILE_NOT_FOUND 21485322600x80100024

The file specified by the pszDirectoryName and pszFileName parameters does not exist.

SCARD_E_INVALID_PARAMETER 21485322280x80100004

The dwFlags parameter contains a value other than zero.

Remarks

When a smart card file is overwritten and the allocated size of the file changes, the available storage of the smart card might become fragmented, resulting in significant loss of useful space. This is because it is usually not possible to implement a memory manager for card storage. For this reason, implementations might choose not to shrink a file if its size has been decreased. Users of this function should be aware that the size of a file might exceed the size of the data contained in that file.

Requirements

Minimum supported client Windows XP, Windows 2000 Professional with SP4
Minimum supported server Windows Server 2003, Windows 2000 Server with SP4
Header Cardmod.h

See Also

Microsoft Base Smart Card Cryptographic Service Provider

CARD_DATA

CardAcquireContext

CardReadFile

Send comments about this topic to Microsoft

Build date: 3/5/2009