Compress function

Takes a block of information and compresses it.

Syntax

BOOL Compress(
  COMPRESSOR_HANDLE CompressorHandle,
  LPCVOID           UncompressedData,
  SIZE_T            UncompressedDataSize,
  PVOID             CompressedBuffer,
  SIZE_T            CompressedBufferSize,
  PSIZE_T           CompressedDataSize
);

Parameters

CompressorHandle

Handle to a compressor returned by CreateCompressor.

UncompressedData

Contains the block of information that is to be compressed. The size in bytes of the uncompressed block is given by UncompressedDataSize.

UncompressedDataSize

Size in bytes of the uncompressed information.

CompressedBuffer

The buffer that receives the compressed information. The maximum size in bytes of the buffer is given by CompressedBufferSize.

CompressedBufferSize

Maximum size in bytes of the buffer that receives the compressed information.

CompressedDataSize

Actual size in bytes of the compressed information received.

Return Value

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.

Remarks

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.

Requirements

   
Target Platform Windows
Header compressapi.h
Library Cabinet.lib
DLL Cabinet.dll

See Also

Compression API Functions