Compress function (compressapi.h)
Takes a block of information and compresses it.
BOOL Compress(
[in] COMPRESSOR_HANDLE CompressorHandle,
[in] LPCVOID UncompressedData,
[in] SIZE_T UncompressedDataSize,
[out] PVOID CompressedBuffer,
[in] SIZE_T CompressedBufferSize,
[out] PSIZE_T CompressedDataSize
);
[in] CompressorHandle
Handle to a compressor returned by CreateCompressor.
[in] UncompressedData
Contains the block of information that is to be compressed. The size in bytes of the uncompressed block is given by UncompressedDataSize.
[in] UncompressedDataSize
Size in bytes of the uncompressed information.
[out] CompressedBuffer
The buffer that receives the compressed information. The maximum size in bytes of the buffer is given by CompressedBufferSize.
[in] CompressedBufferSize
Maximum size in bytes of the buffer that receives the compressed information.
[out] CompressedDataSize
Actual size in bytes of the compressed information received.
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError.
If the compression algorithm fails for some internal reason, the error from GetLastError can be ERROR_FUNCTION_FAILED. If the system cannot locate the compression algorithm handle, the error can be ERROR_INVALID_HANDLE. If the output buffer is too small to hold the compressed data, the error can be ERROR_INSUFFICIENT_BUFFER.
If CompressedBuffer output buffer is too small to hold the compressed data, the function fails and the error from GetLastError can be ERROR_INSUFFICIENT_BUFFER. In this case, the CompressedDataSize parameter receives with the size that the CompressedBuffer needs to be to guarantee success for that input buffer. You can set CompressedBufferSize to zero to determine the size of the output buffer to allocate.
Requirement | Value |
---|---|
Minimum supported client | Windows 8 [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2012 [desktop apps | UWP apps] |
Target Platform | Windows |
Header | compressapi.h |
Library | Cabinet.lib |
DLL | Cabinet.dll |