erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 2, 2009 16:50:45 GMT -5
How can I check, is the file password protected ? I found description of IsEncrypted, but it seems a bit strange to me: property IsEncrypted[Index: Integer: Boolean; Why [ has no ] ?
|
|
|
Post by Kevin on Mar 2, 2009 17:05:06 GMT -5
Looks like a typo in the help file. It should be
property IsEncrypted[Index: Integer]: Boolean;
Just like Filename[Index] it is an indexed property. So you would say something like:
If (VCLZip.IsEncrypted[index]) then ....
Does that help?
|
|
erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 2, 2009 17:16:27 GMT -5
Mm... No. Actually I want to understand, is zip file password protected (and ask user to enter password BEFORE I'll try to unzip it) or not ?
|
|
|
Post by Kevin on Mar 2, 2009 17:21:08 GMT -5
A zip file is not password protected. Each file in the archive is either password protected or not, and each one can have a different password.
If you create an OnBadPassword event, then this will be called whenever a password is needed and you can prompt for one then. Usually all files in an archive have the same password so normally this will only be called one time.
That is why isEncrypted[Index] is an indexed property. It is for each compressed file.
|
|
erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 2, 2009 17:53:23 GMT -5
Aha...
|
|
erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 4, 2009 5:21:19 GMT -5
Sh... Why in our century of globalization u still use NewPassword: AnsiString Do you know that 7Zip support unicode passwords, winrar as I remember no, but it is not good example for imitation
|
|
erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 4, 2009 6:09:33 GMT -5
well, user entered the password, but it's wrong how can I understand it ? If it's wrong I have to ask user to re enter the password... BKZ after 2-nd try to enter wrong password i do not get event BadPassword more and more just 2 trys
|
|
|
Post by Kevin on Mar 4, 2009 7:22:02 GMT -5
Sh... Why in our century of globalization u still use NewPassword: AnsiString Do you know that 7Zip support unicode passwords, winrar as I remember no, but it is not good example for imitation You can use a UTF8String for password and that will allow you to use Unicode for your password. This was done because of the way PKZip handles passwords. But using UTF8 it works.
|
|
|
Post by Kevin on Mar 4, 2009 7:46:25 GMT -5
well, user entered the password, but it's wrong how can I understand it ? If it's wrong I have to ask user to re enter the password... BKZ after 2-nd try to enter wrong password i do not get event BadPassword more and more just 2 trys VCLZip will continue to call OnBadPassword until you do not modify the NewPassword parameter. You must have entered the same password the second time. Make sure you are modifying the NewPassword parameter that is passed into the OnBadPassword event, don't modify the Password property directly in the event.
|
|
erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 28, 2009 13:42:04 GMT -5
VCLZip will continue to call OnBadPassword until you do not modify the NewPassword parameter. You must have entered the same password the second time. So after second try to enter wrong pasword, my unzip procedure will be continued to run How can I stop this? I want to stop do anything further until I'll not get right password. How can I do this ?
|
|
erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 28, 2009 13:51:48 GMT -5
Count BadPassword event calls and exit from unzip procedure after 2-nd ?
|
|
erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 28, 2009 14:44:55 GMT -5
May be I simple should use DecryptHeaderByte ? or DecryptHeader ? To check if password right or not ? But I totally do not understand how to use them Could you provide example in couple strings
|
|
|
Post by Kevin on Mar 29, 2009 8:54:10 GMT -5
No, I am not sure what you are doing, but there is not count of 2 for checking bad passwords. It will continue if, the second time, the user enters the same password or just do not modify the NewPassword parameter. If you leave that parameter the same, VCLZip will skip the file and move to the next one. But remember, it is the NewPassword parameter that you have to set in the OnBadPassword event, not the Password property.
If you want to add a button that says cancel, then you can raise an exception (like EUserCanceled) from the OnBadPassword event when the user does that and that will allow you to catch that exception at the point where you called UnZip.
Kevin
|
|
erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 29, 2009 10:17:49 GMT -5
I need way to stop trys to enter the same wrong password 3 or more times.
|
|
erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 29, 2009 10:23:22 GMT -5
VCLZip will skip the file and move to the next one. I do not need this. I want to exit from with frmMain.Zipper do begin ZipName := RestoreFilename; // set the zip filename RootDir := 'Settings'; FilesList.Add('*.*'); DestDir := TmpFolder; // Set destination directory DoAll := False; Unzip; end;
// Here! If password is wrong and entered 3-time I get here... But Here I want to exit from this procedure if 3-d time password is the same and it's wrong. Hou can i do this ?
|
|