2009년 04월 07일
[Comp] CAB
Introduction
With this project, C++ and .NET programmers get a very versatile library for compression and extraction of Microsoft CAB files.
.NET 1.1 does not offer compression functionality. .NET 2.0 offers the System.IO.Compression.GZipStream class. But this is awkward to use and very primitive; it can only compress a stream but it is not possible to compress folders containing files and subfolders.
If you search the internet for more comfortable compression libraries, you find, for example, ICSharpCode.SharpZipLib.dll which offers ZIP compression. But this library is awkward to use and buggy, and so is unusable. Although the bugs have been known for years, the author has not fixed them.
I asked myself why should I search for another open source library (which will again have other bugs) while Windows itself supports CAB archives since the first days? Microsoft's Cabinet.dll (in the System32 directory) is not buggy. Many Microsoft installers (like the installer for Internet Explorer or Windows patches) use it. Additionally, CAB reaches a much better compression ratio than ZIP. Finally I found the project "Microsoft Cabinet Templates" by Luuk Weltevreden on CodeProject. He created a very versatile wrapper around Microsoft's Cabinet.dll, consisting of C++ templates.
But he didn't even do half of the work. He wrote good extraction classes, but the compression class was completely missing. I worked on his code, fixed a serious bug, simplified some awkward code, removed the templates, and added the missing compression functionality, encryption, Unicode support, internet extraction and more. Additionally, I added all files you need to compile the project. There is no need to download anything from Microsoft anymore.
Features
- This library is VERY easy to use.
- This library is lightweight and VERY fast. (pure C++ code)
- This library can be extended very easily.
- One project is for C++ developers.
- Another project is for .NET developers.
- Both projects compile on Visual Studio .NET (7.0), .NET 2003 (7.1) and .NET 2005 (8.0).
- The C++ project additionally compiles on Visual Studio 6.
- The C++ project runs on Windows 95, 98, ME, NT, 2000, XP, Vista and higher.
- The .NET project runs on all platforms where the .NET framework is installed.
- Optional Encryption / Decryption of CAB files.
- CAB files can contain trees of subfolders and files.
- File dates (in either UTC or local time) and file attributes are preserved when compressing / extracting.
- Extraction of CAB files which are embedded in the resources of your Win32 project or .NET project.
- In .NET, you can additionally extract CAB files from a stream.
- The compression can split large CAB files into multiple pieces. (Pack1.cab, Pack2.cab, Pack3.cab, etc)
- An event handler allows to display the compression / extraction progress in the GUI of your application.
- A lot of event handlers are called during compression and extraction which allows to interact with the progress (for example, filtering specific files)
- Both projects come with a demo application which shows how to compress and extract files and embedded CAB resources. Encryption and Decryption is also included in the demo.
- This project makes use of Microsoft's Cabinet.dll in your System(32) directory, which is part of the operating system since Windows NT/98.
- Cabinet.dll will be loaded only when it is needed and unloaded afterwards. You can also link statically and the external DLL is not required.
- No additional Microsoft downloads required to compile and run this project.
- The C++ and the .NET projects support Unicode in paths and filenames (e.g. Japanese) independent if compiled as MBCS or UNICODE.
- The .NET library is thread safe.
- The .NET library is strong named, it can be installed into the GAC with gacutil.exe.
Version History
- Since version Jan 2007, Msvcp70/71/80.DLL is not required anymore.
- Since version Oct 2007, Msvcr70/71.DLL is not required anymore if CabLib is compiled on Visual Studio 2003.
- Since version Apr 2008, you can extract CAB files directly from a server, (URL extraction from HTTP(S) / FTP).
- You can even extract only specific files out of a CAB on a server without downloading the entire CAB file. (partial download)
- You can also abuse this library to only download a file (MP3, AVI,..) from the internet to disk without CAB extraction.
- Since version May 2008, the .NET library also extracts files with the extensions .URL or .LNK.
- Since version Jun 2008, the encryption/decryption of CAB files uses the Blowfish algorithm. (see below)
- Since version Aug 2008, the creation of CAB archives without compression is supported.
- Since version Sep 2008, you can extract directly to memory. Additionally UTF7 was replaced with UTF8.
- Since version Oct 2008, both projects can be compiled as 32 Bit or 64 Bit version.
- Since version Jan 2009, you can turn off UTF8 encoding. (See below!)
- Since version Feb 2009, you can link Cabinet.dll statically. (See Defines.h)
- Since version Mar 2009, CabLib.dll is strong named.
- You can download Universal Installer (incl sourcecode) which uses the CabLib Library for software setups and updates.
This application demonstrates all the available CabLib features like URL extraction, extraction to memory, display the progress in a progressbar, etc..
이 글과 관련있는 글을 자동검색한 결과입니다 [?]
- .inf파일 분석 by S2nNAMU
- 비주얼스튜디오 2008에서 새로운 점 by 화이부동
- Procedure about setup issue for troubleshooting by kikiwaka
- 캡파일 캡파일 설치 by S2nNAMU
- DLL 관련 유용한 글 by 열혈프로그래머
# by | 2009/04/07 10:06 | ┗▷▶▷ GameDev | 트랙백 | 덧글(0)














☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]