Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Example of extracting zipfile using DynaZip
Message
De
04/06/2002 14:28:55
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00664640
Message ID:
00664654
Vues:
30
Chris,

Think fellows will post you an example code using OOP, so I decided to post an example showing the unzip operation using the "Easy" interface (it works much the same as the OOP way, just doesn't have its "glamour"):
nRetCode = MakeEasyUnZip (cZipFileName  ,  && Name of the Zip file to be unziped            
                          cFileSpec     ,  && what files (ex: *.Doc, *.*, etc)              
                          cToDirectory  ,  && Destination path for the extracted files (ex: c:\Temp\)   
                          .T.)             && Show unzip operation status
. . .

 Function MakeEasyUnzip
*-------- -------------
 LParameters pZipFileName, pFileSpec, pToDirectory, pShowStatus

 Declare Integer GetSystemDirectory In Kernel32.Dll String  @lpBuffer, Integer uiSize

 cWindowsDir = Space (256)

 GetSystemDirectory (@cWindowsDir, Len (cWindowsDir))

 cWindowsDir = AddBS (cWindowsDir)

 bShowStatus = IIf (pCount () > 3, pShowStatus, .T.)

* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 Declare Integer dunzstart    In cWindowsDir + "dz_ez32"
 Declare Integer setunzvalue  In cWindowsDir + "dz_ez32" Integer id, Integer iValue, Integer
 Declare Integer getunzvalue  In cWindowsDir + "dz_ez32" Integer id, Integer iValue
 Declare Integer setunzstring In cWindowsDir + "dz_ez32" Integer id, Integer, String @lpTheString
 Declare Integer getunzstring In cWindowsDir + "dz_ez32" Integer id, Integer, iValue, String @lpTheString, Integer StringLen
 Declare Integer dunzeasy     In cWindowsDir + "dz_ez32" Integer id
 Declare Integer dunzend      In cWindowsDir + "dz_ez32" Integer id

 #Define UNZIP_EXTRACT   8

 #Define UNZ_FUNCTION    0
 #Define UNZ_ZIPFILE     1
 #Define UNZ_FILESPEC    2
 #Define UNZ_DESTINATION 4
 #Define UNZ_OVERWRITE   7

 #Define UNZ_SUBOPTIONS   19
 #Define UNZ_EXTPROGTITLE 20
 
 #Define USO_OVERWRITE_RO    1
 #Define USO_MINORCANCEL     2
 #Define USO_EXTERNALPROG    4
 #Define USO_EXTPROGCANCEL   8
 #Define USO_IGNORELONGNAMES 16
 #Define USO_MANGLELONGNAMES 32
 
 #Define USO_FORCEREMOVEABLE 128
 #Define USO_LOGZIPRESULTS   256

* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 nRegisterId = DUnzStart ()
 nReturnCode = -1

 If nRegisterId <> -1
    nReturnCode = SetUnzValue (nRegisterId, UNZ_FUNCTION, UNZIP_EXTRACT)  
 
   If nReturnCode <> -1
      nReturnCode = SetUnzString (nRegisterId, UNZ_ZIPFILE, AllTrim (pZipFileName))
   endIf
 
   If nReturnCode <> -1
      nReturnCode = SetUnzString (nRegisterId, UNZ_FILESPEC, AllTrim (pFileSpec))
   endIf
  
   If nReturnCode <> -1
      nReturnCode = SetUnzString (nRegisterId, UNZ_DESTINATION, AllTrim (pToDirectory))
   endIf
 
   If nReturnCode <> -1
      nReturnCode = SetUnzValue (nRegisterId, UNZ_OVERWRITE, .T.)
   endIf

   If bShowStatus
      If nReturnCode <> -1
         nReturnCode = SetUnzValue  (nRegisterId, UNZ_SUBOPTIONS, USO_EXTERNALPROG)
      endIf
      If nReturnCode <> -1
         nReturnCode = SetUnzString (nRegisterId, UNZ_EXTPROGTITLE, " Unziping files #" + lTrim (Str (nRegisterId)))
      endIf
   EndIf
 
   If nReturnCode <> -1
      nReturnCode = DUnzEasy (nRegisterId)
   endIf
 
   nReturnCode1 = DUnzEnd (nRegisterId)

   If nReturnCode1 = -1
      nReturnCode  = -1
   endIf
   
 EndIf
 
 Return nReturnCode

 EndFunc    && MakeEasyUnzip
You can also check http://fox.wikis.com/wc.dll?Wiki~DynaZip~WIN_COM_DNA.

Hope it helps,

Fernando
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform