home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 17
/
CD_ASCQ_17_101194.iso
/
vrac
/
exzip101.zip
/
UNZIP.DOC
< prev
next >
Wrap
Text File
|
1994-08-08
|
7KB
|
209 lines
UNZIP.DLL
=========
UNZIP.DLL is derived from code for the DOS utility UNZIP v5.0p1 produced by
the Info-Zip group. As such the DLL is public domain and can be freely used
in any program irrespective of whether you have registered your copy
ExamineZip or not. If the DLL is used in a commercial product then no charges
should be made for its inclusion. The code for UNZIP v5.0p1 was obtained from
The Public Domain and Shareware Library (Tel: 0892 663298) and is also
available from many other disk vendors and bulletin boards.
What now follows is a description of how to use UNZIP.DLL with your program.
All code is in C.
The Header File
===============
The following can be taken from this file and used as a header file to access
the functions and capabilties of UNZIP.DLL
/* Start of header file*/
extern void FAR PASCAL _export SetOptions (int action);
extern void FAR PASCAL _export RegisterPattern (LPSTR szZipFilter);
extern int FAR PASCAL _export ProcessZipFile (HWND hwnd, LPSTR szFile);
extern void FAR PASCAL _export ChangeCase (BOOL val);
extern void FAR PASCAL _export AbortUnZip (void);
#define LIST 0
#define TEST 1
#define EXTRACT 2
#define VIEW 3
#define ID_FLUSHOUTPUT 201
#define ID_ZIPDATA 202
#define ID_ZIPCOMMENT 203
#define ID_ERRORMESSAGE 204
#define ID_STATUSMESSAGE 205
#define ID_MULTITASK 206
typedef struct view_info {
LPSTR szInfo;
int len;
DWORD dwBytesRemaining;
BOOL bFirstOutput;
LPSTR szFileName;
} view_info;
typedef struct zip_data {
char szMethod[8];
DWORD compressed_size;
DWORD uncompressed_size;
UINT day, month, year;
UINT hour, min, sec;
int attr;
int ratio;
DWORD filecrc;
LPSTR szFileName;
LPSTR szZIPName;
LPSTR szComment;
} zip_data;
/* End of Header File */
As well as the header file you will also need to create a library file from
the DLL using a program such as Borland's Import Librarian.
The Functions
=============
Below is an example of a section of code to list all *.doc and *.txt files in
the archive text.zip
.
.
SetOptions (LIST);
RegisterPattern ("*.doc *.txt");
int iret = ProcessZipFile (hwnd, "text.zip");
.
.
void FAR PASCAL SetOptions (int action)
This function tells UNZIP.DLL what action you would like to take on the Zip
archive and may be called only once if you would like to perform the same
action on a series of Zip archives.
int action - The action of your choice with the possible values being LIST,
TEST, EXTRACT or VIEW which are defined in the header file.
void FAR PASCAL RegisterPattern (LPSTR szZipFilter)
This function tells UNZIP.DLL what files are to be acted upon in each archive
and may be called only once if you would like to act on the same sort of
files in a series of Zip archives.
LPSTR szZipFilter - Far pointer to a string giving one or more DOS file
filters. Up to 10 file filters can be contained in the
string with each filter separated by a space.
int FAR PASCAL ProcessZipFile (HWND hwnd, LPSTR szFile)
In calling this function UNZIP.DLL will process the archive as requested and
send any consequent messages to the window whose handle is given in the
calling parameters.
HWND hwnd - Handle of the window that UNZIP.DLL will send all its messages to.
LPSTR szFile - Far pointer to a string giving the name of the archive.
Return Value - zero for a succesful completion, a non-zero value if an error
occurs.
void FAR PASCAL ChangeCase (BOOL val)
This function tells UNZIP.DLL whether you want file information converted to
lowercase or to keep the original case. This need be called only once.
BOOL val - TRUE to convert to lowercase, FALSE to keep the original case.
void FAR PASCAL AbortUnZip (void)
This function can be called during the processing of a message sent from
UNZIP.DLL and will cause the function ProcessZipFile to abort its current
task.
The Messages
============
UNZIP.DLL communicates with the calling program via a series of messages
which are WM_COMMAND messages with the wParam value being described by the
identifiers in the header file and the lParam value either pointing to some
data or having a value of zero.
ID_FLUSHOUTPUT
This message is sent to the calling window procedure when the function
ProcessZipFile is called with the VIEW option. The value of lParam is a far
pointer to a view_info structure defined in the header file. The members of
the structure contain the following information.
LPSTR szInfo - far pointer to the buffer containing the output.
int len - number of bytes of output.
DWORD dwBytesRemaining - the number of bytes yet to be uncompressed from the
archive and to be sent as output.
BOOL bFirstOutput - TRUE if this the first output for a particular file,
FALSE if not.
LPSTR szFileName - far pointer to the filename.
ID_ZIPDATA
This message is sent to the calling window procedure when the function
ProcessZipFile is called with the LIST option. The value of lParam is a far
pointer to a zip_info structure defined in the header file. The members of
the structure contain the following information.
char szMethod[8] - contains the name of the compression method used.
DWORD compressed_size - the size of the file compressed in the archive.
DWORD uncompressed_size - the size of the file if extracted to disk.
UINT day, month, year - the day, month and year that the file was created.
UINT hour, min, sec - the hour, minute and second that the file was created.
int attr - the DOS file attribute.
int ratio - the compression ratio. 0 no compression, 1000
maximum compression. Divide by 10 to get the percent
compression.
DWORD filecrc - 32 bit file CRC.
LPSTR szFileName - far pointer to the filename.
LPSTR szZIPName - far pointer to the archive name.
LPSTR szComment - far pointer to the file comment. If there is no
comment then this is NULL;
ID_ZIPCOMMENT
This message is sent to the calling window procedure when the function
ProcessZipFile is called with the LIST option. It describes the Zip archive
comment if any. The value of lParam is a far pointer to a view_info structure
defined in the header file and described above for the ID_FLUSHOUTPUT
message. If there is no comment then lParam has a value of NULL.
ID_ERRORMESSAGE
This message is sent to the calling window procedure when UNZIP.DLL comes
across an error condition. The value of lParam is a far pointer to text
describing the error condition.
ID_STATUSMESSAGE
This message is sent at least once to the calling window procedure while
ProcessZipFile is operating. The value of lParam is a far pointer to text
describing the current status of the process i.e "Testing: readme.txt".
ID_MULTITASK
This message is sent at least once to the calling window procedure while
ProcessZipFile is operating. The message sends no information but allows the
main program to process other messages in a message queue if desired to give
multitasking capabilities. It can give an opportunity to check whether the
user still wants to continue with the current operation.