Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating & Extracting ZIP files?
Message
 
À
23/12/2003 11:42:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00859913
Message ID:
00861678
Vues:
17
Alan;

For a manual process, right-click on an empty area of Win Explorer or desktop and select "New > Compressed (zipped) folder" - then simply drag files into the newly created 'zipped folder'.

To automate the process (although I have not tried it) I would simply create a new file of type zip, and then save, copy or move files to that location as if it were a directory.

HTH

>Micheal,
>
>I can't find Zip compression or extraction in my copy of Windows XP.
>
>There is some discussion of compression formats, in the Win32API calls, to enable you to compress and decompress either a file or directory. This is a long way from the Zip facility of combining files into one compressed archive with diskette spanning, etc.
>
>It is possible to get this limited compression under XP, by right clicking the file name, selecting properties then Advanced then checking 'Compress contents to save disk space'.
>
>I had a go at trying to do this (see code below) using the API calls but came unstuck at DeviceIoControl. I expect it's obvious to an expert, but I can't get this call to return True.
>
>Help anyone?
>
>Alan
>
>
>lpFileName = 'C:\temp\fredold.txt'
>* This file exists and has been compressed
>
>* Get the file handle for read and write
>#DEFINE OPEN_EXISTING        0x00000003
>#DEFINE GENERIC_READ         0x80000000
>#DEFINE GENERIC_WRITE        0x40000000
>#DEFINE INVALID_HANDLE       -1
>
>DECLARE INTEGER CreateFile IN kernel32 ;
>        STRING  @ lpFileName          ,;
>        INTEGER dwDesiredAccess       ,;
>        INTEGER dwShareMode           ,;
>        INTEGER @ lpSecurityAttributes,;
>        INTEGER dwCreationDistribution,;
>        INTEGER dwFlagsAndAttributes  ,;
>        INTEGER hTemplateFile
>
>dwDesiredAccess = GENERIC_READ + GENERIC_WRITE
>
>hFile1 = CreateFile( ;
>   @lpFileName      ,;
>   dwDesiredAccess  ,;
>   0                ,;
>   0                ,;
>   OPEN_EXISTING    ,;
>   0                ,;
>   0)
>
>IF hFile1 <> INVALID_HANDLE
>
>   #DEFINE COMPRESSION_FORMAT_NONE     0x0000
>   #DEFINE COMPRESSION_FORMAT_DEFAULT  0x0001
>   #DEFINE COMPRESSION_FORMAT_LZNT1    0x0002
>   #DEFINE FSCTL_SET_COMPRESSION       0x00F0
>   #DEFINE FSCTL_GET_COMPRESSION       0x000F
>
>   DECLARE INTEGER DeviceIoControl IN kernel32 ;
>           INTEGER hDevice                    ,;
>           INTEGER dwIoControlCode            ,;
>           STRING  @ lpInBuffer               ,;
>           INTEGER nInBufferSize              ,;
>           STRING  @ lpOutBuffer              ,;
>           INTEGER nOutBufferSize             ,;
>           STRING  @ lpBytesReturned          ,;
>           STRING  @ lpOverlapped
>	
>   dwIoControlCode = FSCTL_GET_COMPRESSION
>   lpInBuffer = ''
>   nInBufferSize = 0
>   lpOutBuffer = '  '
>   nOutBufferSize = 2
>   lpBytesReturned = '    '
>
>   * Find current compression of the file using DeviceIoControl
>   RetVal = DeviceIoControl(    ;
>         hFile1                ,;
>         FSCTL_GET_COMPRESSION ,;
>         @lpInBuffer           ,;
>         nInBufferSize         ,;
>         @lpOutBuffer          ,;
>         nOutBufferSize        ,;
>         @lpBytesReturned      ,;
>         0)
>
>   IF RetVal = 0 && DeviceIoControl failed
>      MESSAGEBOX('DeviceIoControl failed')
>   ELSE
>     * Two bytes
>      Bufval = 0
>      FOR t = 0 TO 1
>         BufVal = BufVal + ASC(SUBSTR(lpOutBuffer, t+1, 1))*256^t
>      ENDFOR
>      DO CASE
>      CASE BufVal = COMPRESSION_FORMAT_NONE
>         MESSAGEBOX('COMPRESSION_FORMAT_NONE')
>      CASE BufVal = COMPRESSION_FORMAT_LZNT1	
>         MESSAGEBOX('COMPRESSION_FORMAT_LZNT1')
>      ENDCASE
>   ENDIF
>
>ENDIF
>
>* Close the file
>IF hFile1>0
>   DECLARE INTEGER CloseHandle IN kernel32 ;
>           INTEGER hObject
>   lnClosed = CloseHandle(hFile1)
>   IF lnClosed = 0
>      MESSAGEBOX('Failed to close the file')
>   ENDIF
>ENDIF
>
Kogo Michael Hogan

"Pinky, are you pondering what I'm pondering?"
I think so Brain, but "Snowball for Windows"?

Ideate Web Site
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform