Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Zip Zip Hurray
Message
From
09/03/2004 17:31:02
 
 
To
07/03/2004 07:17:10
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00882532
Message ID:
00884604
Views:
20
Hi Alan,

In my test the following case gives an OLE error 'the parameter is incorrect'.
CASE Action = 'zscan'
    This.oFld.Self.Verbs.Item(5).DoIt
But I think you should not worry about this one. The code is helpful enough and people should test and modify things in their own environment when implementing it in their app.
Thanks for the good work.

>Peter,
>
>In the past I have had trouble from time to time with the Document object. I found that putting in delays whilst creating the objects improved reliability. I have reworked the program, which is below. Can you let me know how you get on with it?
>
>There will be no response from me for a week, I'm off skiing; its tough on me I know.
>
>Any pointers on getting a file back out would be appreciated.
>
>I am sending this off now to the VFP Download section.
>
>
>*******************************************************
>*                                                     *
>* A free zip file handler for XP                      *
>*                                                     *
>* Alan Shepard     Mar 2004                           *
>*                                                     *
>* Objective :-                                        *
>* Use built in XP facilities to handle zip files.     *
>*                                                     *
>* Most of the documented verbs work, but some         *
>* are rather iffy .                                   *
>*                                                     *
>* To do :-                                            *
>*    Find a way to extract a file from the zip.       *
>*    Confirm that delay option stabilises oFld.       *
>*                                                     *
>*******************************************************
>
>* Create a text files to play with
>STRTOFILE('Rubbish','C:\temp\fred.txt',0)
>STRTOFILE('More rubbish','C:\temp\joe.txt',0)
>
>* Create an object to handle the zip file
>oZHandler = CREATEOBJECT('ZipHandler')
>
>* Try it out
>WITH oZHandler
>
>   * Zip contents methods (start with 'f').
>   * Zip file methods (start with 'z').
>
>   SET STEP ON
>   * Step over each line below to see the result.
>
>   .Doit('zNew','C:\temp\test.zip') && Create a new zip file.
>   .cZipName = 'C:\temp\test.zip'   && Set the handler to point to the zip file.
>   .nDelay = 100                    && Set the delay in milliseconds.
>
>   .Doit('fAdd','C:\temp\fred.txt') && Place two text files in the zip file
>   .Doit('fAdd','C:\temp\joe.txt')
>
>   * Troublesome methods
>*  .Doit('zProperties')             && Zip file properties. Sometimes works.
>*  .Doit('zExtractTo')              && Extract To. Fails for me. Try it.
>*  .Doit('zShort')                  && Create shortcut. I get 'File copy error' sometimes.
>*  .Doit('zRename')                 && Fails with OLE error.
>*  .Doit('zShort')                  && Creates a shortcut. Sometimes fails.
>   .Doit('zCut')                    && Cut. Seems to do nothing.
>
>   * Methods that work
>   .Doit('fOpen','fred.txt')        && View contents of a text file.
>   .Doit('zOpen')                   && View contents of the zip file.
>   .Doit('fCopy','fred.txt')        && Copy. Copies to clipboard.
>   .Doit('fCut','fred.txt')         && Cut. Seems to do nothing.
>   .Doit('fProperties','joe.txt')   && Properties of joe.txt.
>   .Doit('fDelete','joe.txt')       && Delete.
>   .Doit('zExplore')                && Explore contents of the zip file.
>   .Doit('zSearch')                 && Search contents of a zip file.
>   .Doit('zExtractAll')             && Extract contents of the zip file.
>   .Doit('zScan')                   && Anti Virus scan.
>   .Doit('zCopy')                   && Copy. Copies to clipboard.
>
>ENDWITH
>
>DEFINE CLASS ZipHandler AS Custom
>
>   cZipName  = ''
>   nDelay    = 100
>   oShell    = ''
>   oFld      = ''
>   oIts      = ''
>
>   PROCEDURE Init
>
>      This.oShell = CREATEOBJECT("Shell.Application")
>      DECLARE INTEGER Sleep IN kernel32 AS Sleep ;
>              INTEGER dwMilliseconds
>
>   ENDPROC
>
>   PROCEDURE Doit
>   LPARAMETERS Action,FileName
>
>      Action = LOWER(Action)
>      * All actions starting with 'z' apply to the zip file.
>      * All actions starting with 'f' apply to the contents.
>
>      IF Action = 'znew'
>         This.cZipName = FileName
>      ELSE
>
>         IF EMPTY(This.cZipName)
>            MESSAGEBOX('Can not find zip file '+This.cZipName)
>            RETURN
>         ELSE
>            * Create/renew a Folder object.
>            This.oFld = ''
>            DO WHILE TYPE('This.oFld') <> 'O'
>               This.oFld = This.oShell.NameSpace(This.cZipName)
>            ENDDO
>         ENDIF
>         * Create/renew an Items object.
>         This.oIts = ''
>         =Sleep(This.nDelay)
>         This.oIts = This.oFld.Items
>
>         IF Action = 'f' AND Action <> 'fadd'
>            * Find the file in the Zip.
>            FOR t = 0 TO This.oIts.Count-1
>               IF This.oIts.Item[t].Name = FileName
>                  EXIT
>               ENDIF
>            ENDFOR
>            IF  t = This.oIts.Count
>               MESSAGEBOX('Can not find '+FileName+' in '+This.cZipName)
>               RETURN
>            ENDIF
>         ENDIF
>      ENDIF
>
>      DO CASE
>
>      * Carry out Action on the zip file.
>      CASE Action = 'znew'
>         STRTOFILE('PK'+CHR(0x05)+CHR(0x06)+REPLICATE(CHR(0),18),FileName,0)
>      CASE Action = 'zopen'
>         This.oIts.Item.Verbs.Item[0].DoIt
>      CASE Action = 'zsearch'
>         This.oIts.Item.Verbs.Item[1].DoIt
>      CASE Action = 'zextractto'
>         This.oIts.Item.Verbs.Item[2].DoIt
>      CASE Action = 'zexplore'
>         This.oIts.Item.Verbs.Item[3].DoIt
>      CASE Action = 'zextractall'
>         This.oFld.Self.Verbs.Item(4).DoIt
>      CASE Action = 'zscan'
>         This.oFld.Self.Verbs.Item(5).DoIt
>      CASE Action = 'zcut'
>         This.oFld.Self.Verbs.Item(8).DoIt
>      CASE Action = 'zcopy'
>         This.oFld.Self.Verbs.Item(9).DoIt
>      CASE Action = 'zshort'
>         This.oFld.Self.Verbs.Item(10).DoIt
>      CASE Action = 'zshort'
>         This.oFld.Self.Verbs.Item(11).DoIt
>      CASE Action = 'zrename'
>         This.oFld.Self.Verbs.Item(12).DoIt
>      CASE Action = 'zproperties'
>         This.oFld.Self.Verbs.Item(13).DoIt
>
>      * Carry out Action on the zip contents.
>      CASE Action = 'fadd'
>         This.oFld.CopyHere(FileName,0)
>      CASE Action = 'fopen'
>         This.oIts.Item(t).Verbs.Item(0).DoIt
>      CASE Action = 'fcut'
>         This.oIts.Item(t).Verbs.Item(1).DoIt
>      CASE Action = 'fcopy'
>         This.oIts.Item(t).Verbs.Item(2).DoIt
>      CASE Action = 'fdelete'
>         This.oIts.Item(t).Verbs.Item(3).DoIt
>      CASE Action = 'fproperties'
>         This.oIts.Item(t).Verbs.Item(4).DoIt
>
>      OTHERWISE
>
>         MESSAGEBOX('The action is not supported')
>
>      ENDCASE
>
>   ENDPROC
>
>ENDDEFINE
>
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Previous
Reply
Map
View

Click here to load this message in the networking platform