CloseZipFile - zprec: record, will be filled with zipfile data,
do not change the 'internal' field received from previous calls!
GetFirstInZip - Hi byte=number before period, Lo byte=number after period} {Later versions will be downward compatible} {******************** ZIP central directory access *******************} {The following 3 functions can be called in a loop to retreive all
the files in the given zip file.
GetNextInZip - zipfilename: filename of zip file} {zprec: record, will be filled with zipfile data
GetSupportedMethods - Tests if given file is a zip file (only test for PK#3#4 at the beginning)} {***************** Get Unzip Methods supported by DLL ****************} {Currently (version 0.
GetUnzipDllVersion - PackMethod: supported by unzipfile
0: stored x
1: shrunk x
2.
isZip - Call after last GetNextInZip call to free buffer} {********************* Test if file is a ZIP file
unzipfile - Method 0 supported -> bit 0 = 1,
Method 8 supported -> bit 8 = 1,
etc.
unzipfiletomemory - usage:
in_name: name of zip file with full path
out_name: desired name for out file
offset: header position of desired file in zipfile, found in tZiprec
hFileAction: handle to dialog box showing advance of decompression (optional),
or zero when only keyboard shall be checked
cm_index: - if hfileaction<>0 : notification code sent in a wm_command
message to the dialog to update percent-bar
- if hfileaction=0 : virtual key code of key the user must press
to interrupt unzipping, i.
UnzipTestIntegrity - usage:
in_name: name of zip file with full path
out_buf: buffer to recieve unpacked file
buf_size: size of buffer to recieve unpacked file
offset: header position of desired file in zipfile
hFileAction: handle to dialog box showing advance of decompression (optional)
cm_index: notification code sent in a wm_command message to the dialog
to update percent-bar
Return value: one of the above unzip_xxx codes
procedure CloseZipFile(var Zprec:tPackrec);
zprec: record, will be filled with zipfile data,
do not change the 'internal' field received from previous calls!
function GetFirstInZip(zipfilename:pchar;var zprec:tPackRec):integer;
Hi byte=number before period, Lo byte=number after period} {Later versions will be downward compatible} {******************** ZIP central directory access *******************} {The following 3 functions can be called in a loop to retreive all
the files in the given zip file.
Use these functions similar to findfirst and findnext:
Example:
var r:tziprec;
rc:=GetFirstInZip(zipname,r);
while rc=zip_ok do
DosomethingWithData(r);
rc:=GetNextInZip(r);
end;
closezipfile(r);
case rc of
zip_FileError:messagebox(hwindow,'Error reading ZIP file!',zipname,mb_ok);
zip_InternalError:messagebox(hwindow,'Internal error in ZIP file!',zipname,mb_ok);
end;
function GetNextInZip(var Zprec:tPackrec):integer;
zipfilename: filename of zip file} {zprec: record, will be filled with zipfile data
function GetSupportedMethods:longint;
Tests if given file is a zip file (only test for PK#3#4 at the beginning)} {***************** Get Unzip Methods supported by DLL ****************} {Currently (version 0.1) these are stored (0), imploded (6) and deflated (8
function GetUnzipDllVersion:word;
PackMethod: supported by unzipfile
0: stored x
1: shrunk x
2..5:reduced x
6: imploded x
7: tokenized (format does not exist)
8: deflated x
{**************************** DLL Version usage:
in_name: name of zip file with full path
offset: header position of desired file in zipfile
hFileAction: handle to dialog box showing advance of decompression (optional)
cm_index: notification code sent in a wm_command message to the dialog
to update percent-bar
crc: Returns the CRC of the file, compares itself with CRC stored in header
Return value: one of the above unzip_xxx codes
{
function isZip(filename:pchar):boolean;
Call after last GetNextInZip call to free buffer} {********************* Test if file is a ZIP file
function unzipfile(in_name:pchar;out_name:pchar;attr:word;offset:longint;
hFileAction:hwnd;cm_index:integer):integer;
Method 0 supported -> bit 0 = 1,
Method 8 supported -> bit 8 = 1,
etc.} {********************* unzip a file from ZIP-file
function unzipfiletomemory(in_name:pchar;out_buf:pchar;var buf_size:longint;
offset:longint;hFileAction:word;cm_index:integer):integer;
usage:
in_name: name of zip file with full path
out_name: desired name for out file
offset: header position of desired file in zipfile, found in tZiprec
hFileAction: handle to dialog box showing advance of decompression (optional),
or zero when only keyboard shall be checked
cm_index: - if hfileaction<>0 : notification code sent in a wm_command
message to the dialog to update percent-bar
- if hfileaction=0 : virtual key code of key the user must press
to interrupt unzipping, i.e. vk_escape
Return value: one of the above unzip_xxx codes
Example for handling the cm_index message in a progress dialog:
unzipfile(......,cm_showpercent);
...
procedure TFileActionDialog.wmcommand(var msg:tmessage);
var ppercent:^word;
begin
TDialog.WMCommand(msg);
if msg.wparam=cm_showpercent then begin
ppercent:=pointer(lparam);
if ppercent<>nil then begin
if (ppercent^>=0) and (ppercent^<=100) then
SetProgressBar(ppercent^);
if UserPressedAbort then
ppercent^:=$ffff
else
ppercent^:=0;
end;
end;
end;
end;
function UnzipTestIntegrity(in_name:pchar;offset:longint;
hFileAction:word;cm_index:integer;var crc:longint):integer;
usage:
in_name: name of zip file with full path
out_buf: buffer to recieve unpacked file
buf_size: size of buffer to recieve unpacked file
offset: header position of desired file in zipfile
hFileAction: handle to dialog box showing advance of decompression (optional)
cm_index: notification code sent in a wm_command message to the dialog
to update percent-bar
Return value: one of the above unzip_xxx codes