CompressBuffer
BOOL CompressBuffer(
LPVOIDlpvInputBuffer,  
DWORD cbInputBuffer  
LPVOIDlpvOutputBuffer,  
LPDWORD lpcbOutputBuffer  
);

The CompressBuffer function compresses the contents of the specified buffer.

Parameters

lpvInputBuffer
A pointer to the buffer which contains the data to be compressed.
cbInputBuffer
The number of bytes in the input buffer. This value must be greater than zero.
lpvOutputBuffer
A pointer to the buffer which will contain the compressed data. This parameter may be NULL, which can be used to determine the size of the of the resulting compressed data prior to allocating memory for it.
lpcbOutputBuffer
A pointer to the number of bytes that may be copied into the output buffer. If the lpvOutputBuffer parameter is not NULL, this must be initialized to a non-zero value. When the function returns, the actual number of bytes of compressed data is returned in this parameter.

Return Value

A non-zero value is returned if the data was successfully compressed. A zero value indicates that the data could not be compressed.

Remarks

The compression ratio achieved by the CompressBuffer function depends on the type of data that is being compressed. The compressed data can be expanded to its original contents by calling the ExpandBuffer function.

Example

cbOutputBuffer = 0;
bResult = CompressBuffer(lpInputBuffer,
                         cbInputBuffer,
                         NULL,
                         &cbOutputBuffer);

if (bResult)
{
    lpOutputBuffer = (LPBYTE)LocalAlloc(LPTR, cbOutputBuffer);
    bResult = CompressBuffer(lpInputBuffer,
                             cbInputBuffer,
                             lpOutputBuffer,
                             &cbOutputBuffer);
}
      

Requirements

Client: Requires Windows Vista, Windows XP or Windows 2000 Professional.
Server: Requires Windows Server 2008, Windows Server 2003 or Windows 2000 Server.
Header: Include cstools6.h.
Library: Use csncdav6.lib.
Unicode: Implemented as Unicode and ANSI versions.

See Also

CompressFile, DecodeFile, EncodeFile, ExpandBuffer, ExpandFile


Copyright © 2008 Catalyst Development Corporation. All rights reserved.