http://www.7-zip.org/sdk.html
I can uses it compress a file, but can not find function of compress a Folder
You'll have to create a .7z
archive, then include all files of the folder within. There is no direct "folder" compression: just compression of files. If you store a (relative) folder name within the file name (e.g. 'FolderName\FileName'), the folder 'FolderName' will appear within the archive.
You have within the SDK a ANSI-C compatible source code for 7z decompression with example.
You'll have to adapt it to add all files of the folder to the archive (using FindFirst / FindNext / FindClose
and recursion if you want the sub-folder to be included).
Edit: In fact, there is no .7z writing in the sdk. Only opening/extraction from a .7z archive within the sdk. You'll have to code it by hand... So perhaps the Using 7-Zip from Delphi? answer will help you here.
来源:https://stackoverflow.com/questions/10260241/how-to-compress-a-folder-uses-lzma-sdk