Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi







Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (14)


Use Cabinet.dll to create your own cabinet Files Updated(4)Component available for this articleFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi all versions
Category:
Files Operation
Skill Level:
Scoring:
Last Update:
06/25/2001
Search Keys:
delphi delphi3000 article borland vcl code-snippet Cabinet.dll FCI FCICreate FCIFlushFolder FCIAddFile
Times Scored:
11
Visits:
9694
Uploader: Vimil Saju
Company: Nil
Reference: N/A
Component Download: ../article/1820/Attachements.zip
 
Question/Problem/Abstract:
How to use cabinet.dll to create cabinets?
Answer:



I have created a component that enables one to compress files to a cabinet file. This component requires the cabinet.dll which usually resides in your system folder. This component consists of two units. The first unit contains all the structures required by the component.

I have updated the Cabinet unit. now you can add file by using wild cards.
The Compression now takes place in a separate thread,so that you program won't freeze. I have fixed the bug in Onstatusevent. It shows the progress correctly now. I have added an abort function which can be called during the compression process so to cancel compression.You can now specify th directory in which you
want to decompresss the file using the 'addfile function'

I have added the decompress facility, though it is not yet perfected. The Decompressor and compressor run in separate threads so that the application does not freeze. You can also get the list of files present in a cabinet without extracting them. Many bugs were removed. Now there are two components
TCabCompressor and TCabDecompressor.

To select an individual  file to decompress you have to first select it by calling the funtion cabdecompressor1.Files[0].Select. To select all files you can call the function cabdecompressor1.SelectAllFiles and to select files using wildcards use the function cabdecompressor1.SelctFilesByWildCard.

The BeforeCopyFile event in TCabDecompressor Class has been updated to include a parameter called overwrite which indicates wetther the file being decompressed
will overwrite an existing file or not.

The two units along with a demo program are available for download from the download option above.





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
Directory Structures
    Allan MacKinnon (Oct 16 2001 11:12PM)

Great work.

However, is it possible to compress the contents of a directory, and sub directories, preserving the directory info for each file within the cab for decompression?


Respond

RE: Directory Structures
Vimil (Oct 17 2001 11:21AM)

Yes this info can be stored along with the cabinet file. But this information will not be recognised by programs that uncompress cabinet files such as WinZip. We must create our own archival program for uncompressing such cabinet files.
Respond

RE: RE: Directory Structures
Pedro Gomes (Oct 30 2001 7:21PM)

you don't need any software to read these files because Windows Explorer can read them itself
Respond

RE: RE: RE: Directory Structures
Vimil Saju (Oct 31 2001 8:35AM)

yes. I have updated the code and I will post them as soon as possible.
Respond

Cabinet DLL code errors
    Bill Artemik (Feb 19 2001 6:03AM)

I have not tried this code as of yet but after reading the comments above I'll wait. Might I suggest that you add the Uncompress capability (as you seem to understand all this better than I do after a cursory glance at the code) and test this before reposting working version?

I am very interested in this if it is working...it is a nobel effort if it all works as planned.

Bill
Respond

RE: Cabinet DLL code errors
Vimil Saju (Feb 19 2001 7:27AM)

The code isn't as complicated as it looks.
There are only 3 functions that are required to compress files. The list of functions exported by Cabinet.dll and the parameters of each function are available in the download section of the article. you only have to get an idea how each function works. I will add the decompress routine as soon as possible.


The first one is

FCICreate
This function returns a context (a unique value) which is required in the remaining functions.It works almost in the same way as GetDC function in Win32API which returns a context. Using this context you can change a lot of attributes of the DC such as its background color. (The GetDC function and FCICreate are totally different functions that use the same approach to change properties)

the next function is

FCIADD

This function is used to add a fileto the cabinet.To add more than one file,call this function more than once.

FCIDestroy

Once you have added all the required files to the cabinet,you have to call this function to release the memory and delete temporary files created by cabinet.dll.
Respond

UnCabinet.dll
    mcLaren F1 (Feb 10 2001 3:52AM)

How do I decompress my cab-files with cabinet.dll?
Your component is useful, but I can't make them to files with it.
Respond

RE: UnCabinet.dll
Vimil Saju (Feb 10 2001 7:17AM)

I will add this facility very soon
Respond

MAJOR Errors
    Matthew Barrie (Jan 29 2001 4:33AM)

Wow!  Now can you make one that works?
All I got from compiling your component source into Delphi was a list of errors the size of this page.  There are a lot of "Undeclared Identifier" errors, a lot of "Not enough actual parameters" errors, a few "XXX expected but XXX found" errors, and a lot of "missing operator or semicolon" errors.  Now could you explain how your great package works?  WOW!  Thanks, but if you can get one to work, then I might bother.
Respond

RE: MAJOR Errors
Vimil Saju (Jan 29 2001 7:59AM)

I have attached the list of functions exported by cabinet.dll and how to use these functions. There are actually two units. you should copy each unit into a separate pas file and then compile them. I would be grateful if you could send the list of errors to my email address 'vimilsaju@usa.net'
Thanks for your response.


Respond

RE: MAJOR Errors
Antony ZANETTI (Jan 29 2001 11:26AM)

This units works very good !


Respond

RE: RE: MAJOR Errors
Philippe Marechal (Aug 28 2001 10:35PM)

Hi Vimil,
First I've to thank you as I appreciate your work and use cab files.
I succeeded in compressing cabs and also decompress, but I have an error message after the successfull decompression: access violation at address 0045472D in uncab.exe etc.
Her's the code I use for decompression:


procedure TForm1.Button3Click(Sender: TObject);
begin
  if not(cabdecompressor1.Processing) then
  begin
   cabdecompressor1.CabPathName:='setb.cab';
   cabdecompressor1.TargetPath:=('.\decomp\');
   cabdecompressor1.Files[2].Select:=True;
   cabdecompressor1.Decompress;
   end;
end;
Have I forgotten something?
Best Regards,
Philippe Marechal - Cannes  FRANCE
Respond

RE: RE: RE: MAJOR Errors
Vimil Saju (Sep 9 2001 9:00AM)

There doen't seem to be any problem with the code. Could please send the entire source code to my email address vimilsaju@usa.com.

Thanks
Respond

RE: RE: RE: RE: MAJOR Errors
Philippe Marechal (Sep 10 2001 11:27AM)

OK IT all works fine now, thanks
Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
M. Kleiner
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)