login about faq

So, I'm learning C++ and decided to try this out http://www.chilkatforum.com/questions/2354/how-to-write-a-self-extractor-for-the-windows-os . I made some minor changes in the code. The first program (which joins zip and exe) works fine, but when I try to run and unpack it, this happens:

ChilkatLog:
  OpenZip:
    DllDate: Aug 15 2013
    ChilkatVersion: 9.4.1.42
    UnlockPrefix: myUnlockCode
    Username: COMPUTERNAME:Myusername
    Architecture: Little Endian; 32-bit
    Language: Visual C++ 10.0
    VerboseLogging: 0
    hcCurDate: Wed, 28 Aug 2013 21:37:28 +0400
    hcExpire: 11/2013
    zipPath: C:\program.exe
    oemCodePage: 866
    numCentralDirEntries: 6
    szCentralDir: 557
    posCentralDir: 282294
    Did not find central file header signature.
    index: 0
    filePos: 282294
    Failed.
  --OpenZip
--ChilkatLog

What am I doing wrong? Thanks in advance :) This is the program that joins .zip and .exe together:

    #include <windows.h>
    #include <ckbytedata.h>
    #include <ckfileaccess.h>

    // This program appends a .zip to the end of a .exe
    // The .exe must be a multiple of 4 bytes in length.  If it is not, null bytes are
    // appended to make the size a multiple of 4.
    int main(int argc, char* argv[])
        {
        const char *exeFile = "C:/program.exe";

    CkFileAccess fac;
        int exeSize = fac.FileSize(exeFile);
        int nZeros = 4 - (exeSize % 4);
        if (nZeros < 4)
            {
            CkByteData zeros;
            zeros.appendCharN(0,nZeros);
            // Append the zeros to the .exe
            zeros.appendFile(exeFile);
            }

    // Append the .zip to the .exe
        CkByteData zipData;
        zipData.loadFile("c:/archive.zip");
        zipData.appendFile(exeFile);

    return 0;
    }

This is the program which extracts the archive attached to it:

    #include <windows.h>
    #include <direct.h>
    #include <stdio.h>
    #include <CkZip.h>

    int selfExtract(void)
    {
        char myExePath[1024];
        GetModuleFileName(0,myExePath,1024);

        CkZip zip;

        bool success = zip.UnlockComponent("myUnlockCode");
        if (!success)
        {
        printf("%s\n",zip.lastErrorText());
        return 1;
        }

        success = zip.OpenZip(myExePath);
        if (!success)
        {
        printf("%s\n",zip.lastErrorText());
        return 1;
        }

        _mkdir("C:/extract");
        int numUnzipped = zip.Unzip("C:/extract");
        if (numUnzipped < 0)
        {
        printf("%s\n",zip.lastErrorText());
        return 1;
        }

        zip.CloseZip();

        return 0;
     }

    int main(int argc, char* argv[])
    {
        return selfExtract();
    }

asked Aug 28 '13 at 14:05

eyegrabber's gravatar image

eyegrabber
1112

edited Aug 28 '13 at 14:14


I'm suspecting this is a problem introduced with v9.4.1. Try the v9.4.0 build here:

http://www.chilkatsoft.com/download/chilkat-9.4.0-x86-vc10.zip

I'll test v9.4.1 and will fix the problem, assuming my hunch is correct.

link

answered Aug 28 '13 at 16:16

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

Thanks for the reply! Unfortunately, it still doesn't work but the error message has changed: http://pastebin.com/WCFvvbkC

"Failed to match directory entry with file header (2)" i dont quite understand what it's trying to tell me there :D

(Aug 28 '13 at 18:08) eyegrabber
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×87
×65
×9
×8

Asked: Aug 28 '13 at 14:05

Seen: 1,442 times

Last updated: Aug 28 '13 at 18:19

powered by OSQA