Contents - Index - Previous - Next
UnZipToBufferByIndex method
Applies to
TVCLUnZip component
Declaration
function UnZipToBufferByIndex(var Buffer: PChar; Index: Integer): Integer;
Description
The UnZipToBufferByIndex method unzips the file specified by the Index parameter from the zip file specified by the ZipName property directly to the memory buffer specified by Buffer pointer parameter. The length of the buffer is expected to be able to handle the length of the file being unzipped which can be determined by the UnCompressedSize Property.
If you pass in Buffer with a value of nil then Buffer will be allocated at exactly the size of the uncompressed file by VCLUnZip and passed back to you. It will then be your responsibility to free that memory using a call to FreeMem.
Return Value
The return value will be 1 if the buffer was extracted and 0 if it was not successfully unzipped.
As an example, the following shows how to unzip directly into a String and attach it to a TMemo component as its text:
n := FileDialog.FileBox.ItemIndex; /* Get the index of the file to unzip */
SetLength(Buffer, Zipper.UnCompressedSize[n]); /* Set the length of the string */
BufPtr := @Buffer[1] /* Point a PChar at the first character of the string */;
Zipper.UnZipToBufferByIndex(BufPtr, n ); /* Unzip into the string */
TextMemo.Lines.Text := Buffer; /* Use that string as the TMemo's text */