DL: ZIP Manipulations using Windows features

Good day guys,

here goes a guide how to manipulate ZIP archives using windows functionality. Here will be described technique for zipping and unzipping functionality. Functionality perfectly works on XP/2003/Vista machines. (Haven't tested on 2000 system). Year ago I was writing on mibuso this thing but maybe somebody would like to see complete article on this :)

As most of you know, Zip folders functionality appeared from WindowsXP was launched. So now we can use this feature in our Navision projects. For example client want to export any data from navision, ZIP it and send somewhere. So we will discuss second step: Zip it :)

So let's start by creating needed variables for this functionality (there are no much code to play with it:)):

Shell32 Automation 'Microsoft Shell Controls And Automation'.Shell - Shell Automation
ZIPFolder Automation 'Microsoft Shell Controls And Automation'.Folder  - It will be our Zip Folder
ZipFile File  - Zip File
Filename Text  250 - filename of a file to be transferred
IntVal Integer   - integer value (discussed later)
ZipFileName Text  250 - zip file filename
i Integer- counter

Now let's start writing code:)

ZipFile.CREATE('c:\myzipfolder.zip'); //Zip file created
ZipFile.TEXTMODE(FALSE); // in binary mode
IntVal:=101010256; //here we input zip header (it's 6054B50)
ZipFile.WRITE(IntVal); //it's written here
IntVal:=0; //now we input next zip file information for more info refer to
FOR i:=1 TO 9 DO
  ZipFile.WRITE(IntVal);       // 9 zeros in binary format - int32 type
ZipFile.CLOSE; // ok, proper zip file is prepared
CREATE(Shell32); // now we create shell automation
ZIPFolder:=Shell32.NameSpace('c:\myzipfolder.zip'); //opening our zip file as a folder :)
Filename := 'c:\testfile.txt'; // this file will be compressed into myzipfolder.zip archive 
ZIPFolder.CopyHere(Filename);  // just copying :) nice huh?
CLEAR(Shell32); //vuala:)

Same way you may extract files from zip files. Hope you like it :) Object is in attachment.

  Igor Beeone