|
Post by Heiko Schrder on Mar 18, 2004 17:09:27 GMT -5
Hi Kevin
what's going wrong? I want to check a zip file if it is password encrypted. So, I use your trick with FileIsOk and OnBadPassword. The first check with FileIsOk[0] is ok. But if the password in the PasswortEncryptDlg is definitly correct I can't check the FileIsOk[0] again. It will give back the result false! Do I have to do an trick like the ReadZip after changing the ZipName?
...
Zip.Password := ''; If not Zip.FileIsOK[0] then If not CheckPassword then begin ShowMessage('Password Error!'); exit; end;
...
function TUnzipDlg.CheckPassword: Boolean; begin Result := false;
PasswortEncryptDlg := TPasswortEncryptDlg.Create(NIL); If (PasswortEncryptDlg.ShowModal = mrOK) then begin Zip.Password := PasswortEncryptDlg.PasswortEdit.Text; If Zip.FileIsOK[0] then Result := true; end; PasswortEncryptDlg.Release; FreeAndNil(PasswortEncryptDlg); end;
Best regards Heiko
|
|
|
Post by Kevin on Mar 18, 2004 21:32:53 GMT -5
There is a method called ResetFileIsOK(Index: Integer). But, if you JUST want to find out if a zip file is password encrypted there is a faster easier way. Remember though, that each compressed file in the zip file is either encrypted or not, not the whole zip file. There is an indexed property called IsEncrypted . Just go through the files in the archive and check each one...
For i := 0 to VCLZip.Count-1 do begin if VCLZip.IsEncrypted then begin Result := True; Break; end; end;
Or in your code, instead of checking FileIsOK[0] in your first procedure, just check for IsEncrypted[0] instead and then call your CheckPassword function.
Kevin
|
|
|
Post by Heiko Schrder on Mar 19, 2004 12:20:28 GMT -5
Thanks for your fast response. I will try ResetFileIsOK[].
I will not check each file in the zip. I will check the password protection for the complete zip file.
|
|
|
Post by Kevin on Mar 20, 2004 14:53:34 GMT -5
But that is what I am saying, there is no such thing as password protection for the entire file, only for each individual file. As long as you know for sure that either all files are encrypted or non of them are, then you are ok checking only the first file, otherwise, you need to check each file.
Kevin
|
|