2.9. WD_CardCleanupSetup()

Purpose

Sets a list of transfer cleanup commands to be performed for the specified card on any of the following occasions:

  • The application exits abnormally.
  • The application exits normally but without unregistering the specified card.
  • If the WD_FORCE_CLEANUP flag is set in the dwOptions parameter, the cleanup commands will also be performed when the specified card is unregistered.

Prototype
DWORD WD_CardCleanupSetup(
    HANDLE hWD,
    WD_CARD_CLEANUP *pCardCleanup)
Parameters
NameTypeInput/Output
hWDHANDLEInput
pCardCleanupWD_CARD_CLEANUP* 
• hCardDWORDInput
• CmdsWD_TRANSFER*Input
• dwCmdsDWORDInput
• dwOptionsDWORDInput
Description
NameDescription
hWDHandle to WinDriver's kernel-mode driver as received from WD_Open() [5.2]
pCardCleanupPointer to a card clean-up information structure:
• hCard Handle to the relevant card as received from WD_CardRegister() [2.8]
• Cmds Pointer to an array of cleanup transfer commands to be performed
• dwCmdsNumber of cleanup commands in the Cmds array
• bForceCleanup

If 0: The cleanup transfer commands (Cmd) will be performed in either of the following cases:
• When the application exist abnormally.
• When the application exits normally but without calling WD_CardUnregister() [2.10] to unregister the card.

If the WD_FORCE_CLEANUP flag is set: The cleanup transfer commands will be performed both in the two cases described above, as well as in the following case:
• When WD_CardUnregister() [2.10] is called to unregister the card.

Return Value

Returns WD_STATUS_SUCCESS (0) on success, or an appropriate error code otherwise [A].

Remarks

You should call this function right after calling WD_CardRegister() [2.8].

Example
WD_CARD_CLEANUP cleanup;
BZERO(cleanup);

/* Set-up the cleanup struct with the cleanup information */

dwStatus = WD_CardCleanupSetup(hWD, &cleanup);
if (dwStatus)
{
    printf("WD_CardCleanupSetup failed: %s\n", Stat2Str(dwStatus));
}