void ZipBackup (char *targetdir)
{
char *buff1 = new char [256];
char *buff2 = new char [256];
// Check for the backup directory.
if (!DirectoryExists(zipdir))
CreateDir(zipdir);
// Change to the backup directory.
chdir (zipdir);
// Create the command string for the system call to winzip.
if (FileExists ("c:\\windows\\command\\wzzip.exe"))
{
strcpy (buff1, "wzzip -rp ");
ProgressForm->RichEdit1->Lines->Add ("Run winzip command line addon");
}
// Create the command string for the system call to pkzip.
else if (FileExists ("c:\\windows\\command\\zip.exe"))
{
strcpy (buff1, "zip -r ");
ProgressForm->RichEdit1->Lines->Add ("Run PKzip Compression software");
}
else
{
ProgressForm->RichEdit1->Lines->Add ("The compression software could");
ProgressForm->RichEdit1->Lines->Add ("not be found. ");
return;
}
strcat (buff1, "00000.zip ");
strcpy (buff2, targetdir);
path_dos_check (buff2);
strcat (buff1, buff2);
strcat (buff1, "\\");
strcat (buff1, "*.*");
ProgressForm->RichEdit1->Lines->Add ("The files will now be compressed");
ProgressForm->RichEdit1->Lines->Add (buff1);
if (system(buff1) == -1)
ProgressForm->RichEdit1->Lines->Add ("An error occured while compressing the files");
delete buff1;
delete buff2;
}
this example might help
tomcruz.net