CardWriteFile function

This topic is not current. For the most current information about the Smart Card API, see Smart Card Minidriver Specification.

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
2148532260 (0x80100024)
The file specified by the pszDirectoryName and pszFileName parameters does not exist.
SCARD_E_INVALID_PARAMETER
2148532228 (0x80100004)
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 [desktop apps only]
Minimum supported server
Windows Server 2003 [desktop apps only]
Header
Cardmod.h

See also

Microsoft Base Smart Card Cryptographic Service Provider

CARD_DATA

CardAcquireContext

CardReadFile