none
VFP9 and AZIP32/AUNZIP32

    Întrebare

  • I can use  AZIP32/AUNZIP32.dll on XP machine, but on WIN 7 they do not work.

    What program can I use on WIN 7 instead of them for the same purpose?


    Sandor

    30 iulie 2012 10:42

Răspunsuri

  • Hi Sandor,

    you could try these code snippets which make use of windows shell application object which has embedded functions to work with ZIP files. I haven't tested this code in detail but it should do the job.

    ZIP

    CLEAR
    
    lcFile    = [D:\Archive\myZipArchive.zip]
    lcDir    = [D:\TEMP]
    ?
    ?Zip2Archive( lcDir , lcFile )
    
    FUNCTION zip2Archive as Boolean
         LPARAMETERS vSourceDir as String, vZipFile as String
        DECLARE Sleep IN WIN32API INTEGER
        LOCAL    llReturn as Boolean, liOption as Integer, ;
                loShellObj as Object, loInputObj as Object, loOutputObj as Object, loFile as Object
        llReturn = .F.
        loShellObj = CreateObject( [Shell.Application] )
        IF TYPE( [loShellObj] ) = [O]
            IF NOT FILE( vZipFile )
                STRTOFILE( [] , vZipFile )
            ENDIF 
            loInputObj    = loShellObj.NameSpace( vSourceDir )
            loOutputObj    = loShellObj.NameSpace( vZipFile )
            liOption    = 4 && Do not display a progress dialog box 
            IF TYPE( [loInputObj] ) = [O] AND TYPE( [loOutputObj] ) = [O]
                TRY 
                    FOR EACH loFile IN loInputobj.Items
                        loTargetObjExists = loOutputObj.ParseName( loFile.Name )
                        loSourceObjExists = loInputObj.ParseName( loFile.Name )
                        IF ISNULL( loTargetObjExists )
                            loOutputObj.CopyHere( loFile , liOption )
                            SLEEP( 200 )
                        ELSE  
                            IF loOutputObj.ParseName( loFile.Name ).ModifyDate < loFile.ModifyDate
                                ?loFile.Name + [ can be modified]
                            ELSE 
                                ?loFile.Name + [ must not be modified]
                            ENDIF 
                        ENDIF 
                    ENDFOR 
                    llReturn = .T.
                CATCH 
                    * Place messagebox here
                ENDTRY
            ENDIF 
        ENDIF
        RELEASE loInputObj, loOutputObj, loShellObj, loFile
        RETURN llReturn
    ENDFUNC 

    UNZIP

    lcFile    = [D:\Archive\myZipFile.zip]
    lcDir    = [D:\TEMP]
    UnzipArchive( lcFile , lcDir )
    
    FUNCTION UnzipArchive as Boolean
        LPARAMETERS vZipFile as String, vTargetDir as String
        LOCAL    llReturn as Boolean, liOption as Integer, ;
                loShellObj as Object, loInputObj as Object, loOutputObj as Object
        llReturn = .F.
        
        loShellObj = CreateObject( [Shell.Application] )
        IF TYPE( [loShellObj] ) = [O]
            loOutputObj    = loShellObj.NameSpace( vTargetDir )
            loInputObj    = loShellObj.NameSpace( vZipFile )
            liOption    = 4 && Do not display a progress dialog box.
            IF TYPE( [loInputObj] ) = [O] AND TYPE( [loOutputObj] ) = [O]
                TRY 
                    loOutputObj.CopyHere( loInputObj.Items , liOption )
                    llReturn = .T.
                CATCH 
                    * Place messagebox here
                ENDTRY
            ENDIF 
        ENDIF
        RELEASE loInputObj, loOutputObj, loShellObj 
        RETURN llReturn
    ENDFUNC 


    Gruss / Best regards -Tom 010101100100011001010000011110000101001001101111011000110110101101110011

    • Marcat ca răspuns de Shajdu 30 iulie 2012 12:05
    30 iulie 2012 11:16
    Membru care oferă răspunsuri

Toate mesajele

  • Hi Sandor,

    you could try these code snippets which make use of windows shell application object which has embedded functions to work with ZIP files. I haven't tested this code in detail but it should do the job.

    ZIP

    CLEAR
    
    lcFile    = [D:\Archive\myZipArchive.zip]
    lcDir    = [D:\TEMP]
    ?
    ?Zip2Archive( lcDir , lcFile )
    
    FUNCTION zip2Archive as Boolean
         LPARAMETERS vSourceDir as String, vZipFile as String
        DECLARE Sleep IN WIN32API INTEGER
        LOCAL    llReturn as Boolean, liOption as Integer, ;
                loShellObj as Object, loInputObj as Object, loOutputObj as Object, loFile as Object
        llReturn = .F.
        loShellObj = CreateObject( [Shell.Application] )
        IF TYPE( [loShellObj] ) = [O]
            IF NOT FILE( vZipFile )
                STRTOFILE( [] , vZipFile )
            ENDIF 
            loInputObj    = loShellObj.NameSpace( vSourceDir )
            loOutputObj    = loShellObj.NameSpace( vZipFile )
            liOption    = 4 && Do not display a progress dialog box 
            IF TYPE( [loInputObj] ) = [O] AND TYPE( [loOutputObj] ) = [O]
                TRY 
                    FOR EACH loFile IN loInputobj.Items
                        loTargetObjExists = loOutputObj.ParseName( loFile.Name )
                        loSourceObjExists = loInputObj.ParseName( loFile.Name )
                        IF ISNULL( loTargetObjExists )
                            loOutputObj.CopyHere( loFile , liOption )
                            SLEEP( 200 )
                        ELSE  
                            IF loOutputObj.ParseName( loFile.Name ).ModifyDate < loFile.ModifyDate
                                ?loFile.Name + [ can be modified]
                            ELSE 
                                ?loFile.Name + [ must not be modified]
                            ENDIF 
                        ENDIF 
                    ENDFOR 
                    llReturn = .T.
                CATCH 
                    * Place messagebox here
                ENDTRY
            ENDIF 
        ENDIF
        RELEASE loInputObj, loOutputObj, loShellObj, loFile
        RETURN llReturn
    ENDFUNC 

    UNZIP

    lcFile    = [D:\Archive\myZipFile.zip]
    lcDir    = [D:\TEMP]
    UnzipArchive( lcFile , lcDir )
    
    FUNCTION UnzipArchive as Boolean
        LPARAMETERS vZipFile as String, vTargetDir as String
        LOCAL    llReturn as Boolean, liOption as Integer, ;
                loShellObj as Object, loInputObj as Object, loOutputObj as Object
        llReturn = .F.
        
        loShellObj = CreateObject( [Shell.Application] )
        IF TYPE( [loShellObj] ) = [O]
            loOutputObj    = loShellObj.NameSpace( vTargetDir )
            loInputObj    = loShellObj.NameSpace( vZipFile )
            liOption    = 4 && Do not display a progress dialog box.
            IF TYPE( [loInputObj] ) = [O] AND TYPE( [loOutputObj] ) = [O]
                TRY 
                    loOutputObj.CopyHere( loInputObj.Items , liOption )
                    llReturn = .T.
                CATCH 
                    * Place messagebox here
                ENDTRY
            ENDIF 
        ENDIF
        RELEASE loInputObj, loOutputObj, loShellObj 
        RETURN llReturn
    ENDFUNC 


    Gruss / Best regards -Tom 010101100100011001010000011110000101001001101111011000110110101101110011

    • Marcat ca răspuns de Shajdu 30 iulie 2012 12:05
    30 iulie 2012 11:16
    Membru care oferă răspunsuri
  • Thank you Tom . Its OK

    Sandor

    30 iulie 2012 12:05