Visual C++ Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual C++ Examples

CkString
Byte Array
Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA

Unreleased...
Bzip2
LZW
Bz2
Icon

 

 

 

 

 

 

 

 

How to read a binary structure (.zip header)

Demonstrates calling methods such as getUInt, getUShort, etc. to read integers in a binary structure. In this case, a .zip file is opened and the 1st local file header is examined.

Download Chilkat C++ Libraries for VC++ 8.0 / Win32

Download Chilkat C++ Libraries for VC++ 7.0 / Win32

Download Chilkat C++ Libraries for VC++ 6.0 / Win32

#include <CkByteData.h>

void ChilkatSample(void)
    {
    CkByteData zipData;

    bool success;

    success = zipData.loadFile("dude.zip");
    if (success != true) {
        printf("Failed to load file\n");
        return;
    }

    int offset;
    offset = 0;

    int filenameLen;
    filenameLen = zipData.getUShort(26);

    printf("%s\n",zipData.getRangeStr(30,filenameLen));

    int compressedSize;
    int uncompressedSize;

    compressedSize = zipData.getUInt(18);
    uncompressedSize = zipData.getUInt(22);

    printf("%d\n",compressedSize);
    printf("%d\n",uncompressedSize);

    //  Note: Zip File Structure:
    //  see: http://www.pkware.com/documents/casestudies/APPNOTE.TXT

    //   Overall .ZIP file format:

    //     [local file header 1]
    //     [file data 1]
    //     [data descriptor 1]
    //     .
    //     .
    //     .
    //     [local file header n]
    //     [file data n]
    //     [data descriptor n]
    //     [archive decryption header]
    //     [archive extra data record]
    //     [central directory]
    //     [zip64 end of central directory record]
    //     [zip64 end of central directory locator]
    //     [end of central directory record]

    //   A.  Local file header:

    //         local file header signature     4 bytes  (0x04034b50)
    //         version needed to extract       2 bytes
    //         general purpose bit flag        2 bytes
    //         compression method              2 bytes
    //         last mod file time              2 bytes
    //         last mod file date              2 bytes
    //         crc-32                          4 bytes
    //         compressed size                 4 bytes
    //         uncompressed size               4 bytes
    //         file name length                2 bytes
    //         extra field length              2 bytes

    //         file name (variable size)
    //         extra field (variable size)

    //  ...

    }

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Mail Component · XML Parser