The TWUCleanupDownloads function deletes all downloaded files of the session. You can use this function to clean up the temporary package installer files that were used during the session.

Tip: To prevent deletion of one or more download files, set the szDownloadPath member of their TWUPackageData to an empty string (use pPackage->szDownloadPath[0] = 0; or pPackage^.szDownloadPath[0] := #0; in Delphi)

URESULT TWUCleanupDownloads(
    TWUHANDLE hSession

Delphi version:

function TWUCleanupDownloads(
    hSession: TWUHANDLE


[Input] Handle to an open TWU session.

Return value

If the function succeeds, it returns ERROR_SUCCESS (0). If it fails, it returns a nonzero Win32 API error code. You can use TWUGetErrorMessage to retrieve the error message that corresponds to the error code.