Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

64 bit replacement needed for Dynazip 1

Status
Not open for further replies.

Grandchoir

Programmer
Jul 25, 2024
3
US
I need a 64-bit replacement for Dynazip for use with Visual FoxPro Advanced(x64). Any recommendations?

I can use 7-Zip CLI along with shell_execute, but wondered if anyone has more experience zipping and unzipping files in Visual FoxPro Advanced.

Thank you in advance!

Daniel
 
Thus far, I have been using BandiZip, about 18 months ago I did a lot of testing various zip programs with VFPa
and that was the fastest.

Times change.
 
You could use the Windows API.

To remove files from a zip file:

Code:
    loShell = CREATEOBJECT("shell.application")
    loShell.NameSpace(tcTempPath).CopyHere(loShell.NameSpace(lcZipName).Items, FOF_SILENT)
    lnCnt = 0
    lnCntTot = loShell.NameSpace(lcZipName).Items.Count
    DO WHILE loShell.NameSpace(tcTempPath).Items.Count != lnCntTot
        lnCnt = lnCnt + 1
        apiSleep(100)
        IF lnCnt > lnCntTot
            this.DebugMethod()
        ENDIF
    ENDDO

To add files to a zip file:

Code:
    loShell  = CREATEOBJECT("shell.application")
    loFolder = loShell.NameSpace(tcTempPath).Items
    IF VAL(VERSION(4)) <= 9 .AND. (VAL(OS(3))<6 .OR. VAL(OS(3))=6 .AND. VAL(OS(4))<1)      && Fix for VFPA provided by Doug Hennig; VAL() fix provided by starfiresg1
        FOR EACH loFile IN loFolder
            loShell.NameSpace(tcZipFile).MoveHere(loFile, FOF_SILENT+FOF_NOCONFIRMATION+FOF_NOERRORUI)
            apiSleep(100)
        ENDFOR
    ELSE
        FOR EACH loFile IN loFolder
            lnCountBefore = loShell.NameSpace(tcTempPath).Items.Count
            loShell.NameSpace(tcZipFile).MoveHere(loFile, FOF_SILENT+FOF_NOCONFIRMATION+FOF_NOERRORUI)
            DO WHILE lnCountBefore = loShell.NameSpace(tcTempPath).Items.Count
                apiSleep(50)
            ENDDO
        ENDFOR
    ENDIF
 
Thus far, I have been using BandiZip, about 18 months ago I did a lot of testing various zip programs with VFPa
and that was the fastest.

Times change.
Thank you GriffMG. I'll look into this further.

Daniel
 
You could use the Windows API.

To remove files from a zip file:

Code:
    loShell = CREATEOBJECT("shell.application")
    loShell.NameSpace(tcTempPath).CopyHere(loShell.NameSpace(lcZipName).Items, FOF_SILENT)
    lnCnt = 0
    lnCntTot = loShell.NameSpace(lcZipName).Items.Count
    DO WHILE loShell.NameSpace(tcTempPath).Items.Count != lnCntTot
        lnCnt = lnCnt + 1
        apiSleep(100)
        IF lnCnt > lnCntTot
            this.DebugMethod()
        ENDIF
    ENDDO

To add files to a zip file:

Code:
    loShell  = CREATEOBJECT("shell.application")
    loFolder = loShell.NameSpace(tcTempPath).Items
    IF VAL(VERSION(4)) <= 9 .AND. (VAL(OS(3))<6 .OR. VAL(OS(3))=6 .AND. VAL(OS(4))<1)      && Fix for VFPA provided by Doug Hennig; VAL() fix provided by starfiresg1
        FOR EACH loFile IN loFolder
            loShell.NameSpace(tcZipFile).MoveHere(loFile, FOF_SILENT+FOF_NOCONFIRMATION+FOF_NOERRORUI)
            apiSleep(100)
        ENDFOR
    ELSE
        FOR EACH loFile IN loFolder
            lnCountBefore = loShell.NameSpace(tcTempPath).Items.Count
            loShell.NameSpace(tcZipFile).MoveHere(loFile, FOF_SILENT+FOF_NOCONFIRMATION+FOF_NOERRORUI)
            DO WHILE lnCountBefore = loShell.NameSpace(tcTempPath).Items.Count
                apiSleep(50)
            ENDDO
        ENDFOR
    ENDIF
Thank you for your reply. I'll study this code and see if I can make it work.

Daniel
 
Do you use DynaZip AX (the ActiveX component)? Then you actually don't need a replacement. When using OLE classes you instanciate anything in a new process anyway, no matter if it's an OCX, DLL or EXE, as it usually is foreign language code anyway you start a new runtime process for an ActiveX component.

If not, you could also continue using Dynazip by creating your own 32bit COM Server to use with VFPA, either in VFP9 or VFPA 32Bit. This can be your streting point for that, in a 32bit VFP Project:
Code:
Define Class Zip as Custom OlePublic
   Procedure Zip(tcDirectory)
      * Your code zipping a directory with DynaZip
   EndProc
 
   Procedure Unzip(tcZipFile, tcTargetDirectory)
      * Your code unzipping a zip file with DynaZip
   EndProc
EndDefine
If you call the project Dyna.pjx and build (EXE or DLL, doesn't matter much) your VFP COM Server will be called "Dyna.ZIP".

Otherwise I second Griffs recommendation of BandiZip, though I have not used it. From the product description I see it offers everything you could use with DynaZip, including AES encryption, multiple archive formats support, file spanning, etc.

If you merely zip up some files so you can mail them and the end user of that ZIP does use whatever ZIP software to unzip it, the usage of the shell.application for that is completely sufficient. The only downside and some exotic problem cases you can find here on tek-tips is about progress of the zipping and too early trying to use the not yet completely written ZIP file, you have to understand using shell.application by createobject (OLE/COM automation) is making that a parallel process, which means this works in parallel. The code sample of ggreen does refrain from making much use of that, it merely waits with Sleep until the zipping or unzipping finihes with each single file. At these stages of the code you could also report progress, by the way, at least on which number of file you're working on.
 
Last edited:
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top