Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A single-class pure VB6 library for zip with ASM speed

License

NotificationsYou must be signed in to change notification settings

wqweto/ZipArchive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A single-class pure VB6 library for zip archives management

Usage

Just includecZipArchive.cls to your project and start using instances of the class like this:

Simple compression

With New cZipArchive    .AddFile App.Path & "\your_file"    .CompressArchive App.Path & "\test.zip"End With

Compress all files and sub-folders

With New cZipArchive    .AddFromFolder "C:\Path\To\*.*", Recursive:=True    .CompressArchive App.Path & "\archive.zip"End With

Decompress all files from archive

With New cZipArchive    .OpenArchive App.Path & "\test.zip"    .Extract "C:\Path\To\extract_folder"End With

MethodExtract can optionally filter on file mask (e.g.Filter:="*.doc"), file index (e.g.Filter:=15) or array of booleans with each entry to decompress index set toTrue.

Extract single file to target filename

OutputTarget can include a targetnew_filename to be used when extracting a specific file from the archive.

With New cZipArchive    .OpenArchive App.Path & "\test.zip"    .Extract "C:\Path\To\extract_folder\new_filename", Filter:="your_file"End With

Get archive entry uncompressed size

By usingFileInfo property keyed on entry filename in first parameter andzipIdxSize like this

With New cZipArchive    .OpenArchive App.Path & "\test.zip"    Debug.Print .FileInfo("report.pdf", zipIdxSize)End With

List files in zip archive

By usingFileInfo propery keyed on entry numeric index in first parameter like this

Dim lIdx            As LongWith New cZipArchive    .OpenArchive App.Path & "\test.zip"    For lIdx = 0 To .FileCount - 1        Debug.Print "FileName=" & .FileInfo(lIdx, zipIdxFileName) & ", Size=" & .FileInfo(lIdx, zipIdxSize)    NextEnd With

Here is a list of available values for the second parameter ofFileInfo:

Name
0zipIdxFileName
1zipIdxAttributes
2zipIdxCrc32
3zipIdxSize
4zipIdxCompressedSize
5zipIdxComment
6zipIdxLastModified
7zipIdxMethod
8zipIdxOffset
9zipIdxFlags

Encryption support

Make sure to set Conditional Compilation in Make tab in project's properties dialog to includeZIP_CRYPTO = 1 setting for crypto support to get compiled from sources. By default crypto support is not compiled to reduce footprint on the final executable size.

With New cZipArchive    .OpenArchive App.Path & "\test.zip"    .Extract App.Path & "\test", Password:="123456"End With

UsePassword parameter onAddFile method together withEncrStrength parameter to set crypto used when creating archive.

EncrStrengthMode
0ZipCrypto (default)
1AES-128
2AES-192
3AES-256 (recommended)

Note that default ZipCrypto encryption is weak but this is the only option which is compatible with Windows Explorer built-in zipfolders support.

In-memory operations

Sample utility functionReadBinaryFile in/test/basic/Form1.frm returns byte array with file's content.

Dim baZip() As ByteWith New cZipArchive    .AddFile ReadBinaryFile("sample.pdf"), "report.pdf"    .CompressArchive baZipEnd WithWriteBinaryFile "test.zip", baZip

MethodExtract accepts byte array target too.

Dim baOutput() As ByteWith New cZipArchive    .OpenArchive ReadBinaryFile("test.zip")    .Extract baOutput, Filter:=0    '--- archive's first file onlyEnd With

ToDo (not supported yet)

- Deflate64 (de)compressor- VBA7 (x64) support

[8]ページ先頭

©2009-2025 Movatter.jp