Infozip is a powerful and free Zip/unzip library. In order to facilitate its use, this article will introduce a Infozip packaging class cinfozip, which does not implement the compression function itself, but provides an easy-to-use Infozip DLLs interface (included in the Cinfozip)
How to use the Cinfozip class:
1. Add Cinfozip header files and implementation files to the project, and then copy ZIPDLL.DLL and UNZDLL.DLL files to the directory where the EXE files are located. Zipdll. DLL for compression, Unzdll. DLL for decompression.
2, create the Cinfozip class object in the code and add the initialization method call:
BOOL Cinfozip::initializezip ();
BOOL Cinfozip::initializeunzip ();
BOOL cinfozip::initialize ();
The previous two methods load the Infozip DLLs and get a pointer to the procedure being used, and return true if successful, or false. The last method initializes the zip and unzip two DLLs.
3. Add files or decompress to the compressed document:
BOOL cinfozip::addfiles (const char *pszarchive, char **pafiles, int ifilecount);
BOOL cinfozip::extractfiles (const char *pszarchive, const char * psztargetfolder);
Pszarchive bit an empty end string that contains the full path name of the compressed document, Pafiles is an empty end string array containing the file name for the entire path, Ifilecount is the number of files in the Pafiles array, and Psztargetfolder is a folder full channel, Used to store uncompressed files.
4. Use the compression and decompression method set with predefined parameters:
BOOL cinfozip::setdefaultvalues (Czipparams *pparams);
BOOL cinfozip::setdefaultvalues (Cunzipparams *pparams);
If you want to implement Zip/unzip operations with different parameters, you must create a CZIPPARAMS/CUNZIPPARAMS type structure, populate the structure with the appropriate values (call Setdefaultparams change some struct members), and then call Cinfozip :: Execute Method:
BOOL Cinfozip::execute (Czipparams *pparams);
BOOL Cinfozip::execute (Cunzipparams *pparams);
5. After processing the Cinfozip, call the following method to release the allocated resources and the loaded DLLs:
BOOL Cinfozip::finalizezip ();
BOOL Cinfozip::finalizeunzip ();
BOOL cinfozip::finalize ();
This article supporting source code