7-zip for BDS 2006 组件: http://www.goldray.net/download/7zip.rar
适用于:
Delphi 2006 for win32 与 C++Builder 2006
原件出于:
http://www.rg-software.de/
下载地址:
http://www.rg-software.de/files/SevenZipVCL_074.zip
对于 SevenZipVCL.pas 未做更改。
以下是解压与压缩代码, 仅供参考.
bool __fastcall Extract7Zip(const AnsiString ADestinationPath, AnsiString ASourceFileName)
...{
bool Result = false;
TSevenZip * SevenZip = new TSevenZip(NULL);
try
...{
SevenZip->ExtrBaseDir = ADestinationPath;
SevenZip->ExtractOptions = ExtractOpts() << ExtractOverwrite <<ExtractNoPath;
SevenZip->SZFileName = ASourceFileName;
Result = SevenZip.Extract(false) == S_OK;
}
__finally
...{
delete SevenZip;
}
return Result;
}
bool __fastcall Compress7Zip(const AnsiString ADestinationFileName, TStrings * AFileList)
...{
bool Result = false;
TSevenZip * SevenZip = new TSevenZip(NULL);
try
...{
SevenZip.SZFileName := ADestinationFileName;
SevenZip->Files->Clear;
for (int i = 0; i < AFileList->Count; i++)
SevenZip->Files->AddString(AFileList->Strings[i]);
SevenZip->AddOptions = AddOpts() <<AddStoreOnlyFilename << AddSolid;
SevenZip->LZMACompressType = LZMA;
SevenZip->LZMACompressStrength = NORMAL;
Result = SevenZip->Add() == S_OK;
}
__finally
...{
delete SevenZip;
}
return Result;
}
...{
bool Result = false;
TSevenZip * SevenZip = new TSevenZip(NULL);
try
...{
SevenZip->ExtrBaseDir = ADestinationPath;
SevenZip->ExtractOptions = ExtractOpts() << ExtractOverwrite <<ExtractNoPath;
SevenZip->SZFileName = ASourceFileName;
Result = SevenZip.Extract(false) == S_OK;
}
__finally
...{
delete SevenZip;
}
return Result;
}
bool __fastcall Compress7Zip(const AnsiString ADestinationFileName, TStrings * AFileList)
...{
bool Result = false;
TSevenZip * SevenZip = new TSevenZip(NULL);
try
...{
SevenZip.SZFileName := ADestinationFileName;
SevenZip->Files->Clear;
for (int i = 0; i < AFileList->Count; i++)
SevenZip->Files->AddString(AFileList->Strings[i]);
SevenZip->AddOptions = AddOpts() <<AddStoreOnlyFilename << AddSolid;
SevenZip->LZMACompressType = LZMA;
SevenZip->LZMACompressStrength = NORMAL;
Result = SevenZip->Add() == S_OK;
}
__finally
...{
delete SevenZip;
}
return Result;
}