A infozip packaged class for use in an MFC environment

Source: Internet
Author: User
Tags bool zip

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.