-1

Hello I download Lzma for delphi its 48 kb.What will I do now?How can I use it? Is there any example code for Lzma in DElphi?

Cenk Aybeyaz
  • 155
  • 3
  • 7

2 Answers2

5

Abbrevia 4 supports decompressing LZMA streams in zip files using a statically linked version of the LZMA C SDK. It includes pre-compiled copies of the .c files and links them using {$L abc.obj}, and is up to date (v9.20). AbLZMA.pas has LzDecode and LzEncode functions that are compatible with the files the SDK generates.

Do note that that handles raw Lzma streams though, not the full .7z archive that 7-zip produces. If you need that you're better off using the Jedi Code Library's JclCompression unit.

Zoë Peterson
  • 13,094
  • 2
  • 44
  • 64
  • 1
    thank you..I download jedi code librarys.what will do now? – Cenk Aybeyaz Jun 29 '11 at 21:50
  • 3
    @Cenk: You need to use the TJclCompressArchive/TJclDecompressArchive classes. Start with `GetArchiveFormats.FindCompressFormat` or `FindDecompressFormat` to get a specific subclass and then use the classes's functions to add/remove files. There's some sample code at http://stackoverflow.com/questions/1974736/how-am-i-supposed-to-use-jedis-jclcompression-to-create-a-7z-archive and http://stackoverflow.com/questions/74519/using-7-zip-from-delphi – Zoë Peterson Jun 29 '11 at 21:58
  • 1
    ok I m trying,thank you ı will turn back – Cenk Aybeyaz Jun 29 '11 at 22:00
  • I am sorry ı couldnt install them what can I install them? – Cenk Aybeyaz Jun 29 '11 at 22:08
  • @Cenk: The current JCL release is available for download at https://sourceforge.net/projects/jcl/files/JCL%20Releases/JCL%202.2%20Build%203970/ It includes an Install.txt with installation instructions. Just extract the zip and read through that. – Zoë Peterson Jun 29 '11 at 22:27
  • I think I installed it,ı took a photo on delphi link:http://imageshack.us/photo/my-images/820/ca2ui.jpg/ now what will do? – Cenk Aybeyaz Jun 29 '11 at 22:30
  • @Cenk: JclCompression contains non-visual components. You need to include it in your USES clause, open the .pas file in your editor, and see what you can do. Take a look at the links in my first comment for example code. – Zoë Peterson Jun 29 '11 at 22:39
  • I cant understand..Just I have a text file and I wanna compress it could you write an example code... – Cenk Aybeyaz Jun 29 '11 at 22:46
  • Hello I made it,but there is an error 'load 7z.dll' how can I solve this? – Cenk Aybeyaz Jun 29 '11 at 23:34
  • 1
    @Cenk: I think 7z.dll is part of the 7z922.exe package on SourceForge: https://sourceforge.net/projects/sevenzip/files/7-Zip/9.22/ I don't use it myself though, so you might try the other packages there too. – Zoë Peterson Jun 30 '11 at 00:12
  • See Jason Penny's answer here for a working sample: http://stackoverflow.com/questions/74519/using-7-zip-from-delphi – Warren P Jun 30 '11 at 02:12
2

There is example code within the SDK (LZMAAlone) that is an example of using the decoder. You need to include most of the files under compression/{LZ,LZMA,RangeCoder}/ in your project to get it to work. The SDK doesn't generate a package that could be used as a compile-time/run-time package.

It works using TStreams, so you can use TMemoryStreams if you want to perform compression/decompression without using a file.

BTW the Delphi implementation is at the 4.42 revision, while the official SDK is at 9.20, which is a big difference!

Anya Shenanigans
  • 91,618
  • 3
  • 107
  • 122