First go to the 7z official website to download the code 7z source or Lzma can, but recommended 7z source code, the contents of a relatively full
7z.dll works through COM interfaces. However, it does not use a standard COM interface. It would be easier to see his code if there was a COM base.
The simple example is that/cpp/7zip/ui/client7z has a simple compression decompression and a view of the compressed package file. 7z.dll's source code is inside BUNDLES/7ZFORMATF.
Where the code for clinet7z and file Manager looks better, you can follow your own step-by-step. Update later in the evening
7z.dll works with COM interfaces, but it does not use a standard COM interface.
Unzip the file mainly by the following two callback classes
/Archive Open Callback Class
ZIP File Open Callback class Carchiveopencallback:
Public Iarchiveopencallback,
Public Icryptogettextpassword,
Public Cmyunknownimp
Decompression Callback class Carchiveextractcallback:
Public Iarchiveextractcallback,
Public Icryptogettextpassword,
Public Cmyunknownimp
Unzip the callback class
IProgress
STDMETHOD (settotal) (UInt64 size); Get the total number of compressed files bytes
STDMETHOD (setcompleted) (const UInt64 *completevalue); Gets the current uncompressed file size byte number you can then calculate the current decompression progress in this callback function.
Iarchiveextractcallback
STDMETHOD (GetStream) (UInt32 index, Isequentialoutstream **outstream,int32 askextractmode); Gets the file stream,
LRESULT Myreleasesteam (); When you cancel the decompression, release the file stream control reason to cancel the decompression and not go to the Setoperationresult () callback function, and release the file stream is in this function, so to release itself.
Get interface functions
Createobjectfunc Createobjectfunc = (Createobjectfunc) lib. Getproc ("CreateObject");
Cmycomptr<iinarchive> Archive;
ErrorCode = Createobjectfunc (&clsid_cformat7z, &iid_iinarchive, (void * *) &archive);
Cinfilestream *filespec = new Cinfilestream;
cmycomptr<iinstream> file = FileSpec;
Ustring archivename = getunicodestring (inFile);
if (!filespec->open (archivename))
{
Unable to open the compressed file (the file cannot be found)
return;
}
Carchiveopencallback *opencallbackspec = new Carchiveopencallback;
Cmycomptr<iarchiveopencallback> Opencallback (OPENCALLBACKSPEC);
opencallbackspec->passwordisdefined = false;
ErrorCode = archive->open (file, 0, opencallback);
if (errorcode! = S_OK)
Return
Extract command
Carchiveextractcallback *extractcallbackspec = new Carchiveextractcallback;
Cmycomptr<iarchiveextractcallback> Extractcallback (EXTRACTCALLBACKSPEC);
Extractcallbackspec->init (archive, OutFile); Second parameter is output folder path
extractcallbackspec->passwordisdefined = false;
Extractcallbackspec->setfileinfo (info);
Extractcallbackspec->passwordisdefined = true;
Extractcallbackspec->password = L "1";
ErrorCode = Archive->extract (NULL, (UInt32) (Int32) ( -1), false, Extractcallback);
if (errorcode! = S_OK)
Return
7z Compression class progress bar callback function