Sample code for 30+ languages & platforms
Visual FoxPro

Verify a Zip's Password

See more Zip Examples

Demonstrates how to verify the password for an encrypted or password-protected zip archive.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loZip
LOCAL lnPasswordOk

lnSuccess = 0

* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

loZip = CreateObject('Chilkat.Zip')

* To verify a password for a Zip, the Zip must be opened:
lnSuccess = loZip.OpenZip("myProtected.zip")
IF (lnSuccess <> 1) THEN
    ? loZip.LastErrorText
    RELEASE loZip
    CANCEL
ENDIF

* Set the password to be verified:
loZip.DecryptPassword = "secret"

lnPasswordOk = loZip.VerifyPassword()
IF (lnPasswordOk = 1) THEN
    ? "Password is correct."
ELSE
    ? "Password is incorrect."
ENDIF

loZip.CloseZip()

RELEASE loZip