0

I have multiple executable files. I want to write a program using cpp which will extract them to a specific location. Like unpacking a zip archive but i want it to be an executable and work in any clean install of windows. (vista or later) Is there a way to do it?

Edit: I know how to make a self extracting zip file, i want to learn how can i do it myself.

  • 5
    Have you looked at NOT writing your own code and using a self-extracting zip-file? – Mats Petersson Jul 12 '15 at 15:57
  • "I want to learn how can I do it myself" - I extended my answer. – NO_NAME Jul 13 '15 at 08:01
  • What you are asking is called an installer. There are a *lot* of ways to create installers, both commercial and open source. Don't write your own. Users will be *very* unhappy if don't provide a proper installer. – Panagiotis Kanavos Jul 13 '15 at 08:05

1 Answers1

0

Most of archivers have option to create executable files. You don't need to write own program.

EDIT: If you really want to do all of it by own, you should use windows resource files. (Using of them is describer in another question.) I see two possible ways to do this.

  1. Add every single file to your program, as a resource. Program should remember name of each file and save them to directory one by one.
  2. Pack all the files into one. (You need to write second program to pack the files.) Exemplary format of the package can be as follows:

    | 4-bytes - length of 1st filename | 1st filename | 4-bytes size of 1st file | 1st file | 4-bytes - length of 2nd filename | ...

    Package prepared in this way can be put into program resources. This is a more difficult method but it is also more elastic. You can modify the list of files without changing anything in the program.

Community
  • 1
  • 1
NO_NAME
  • 2,769
  • 1
  • 23
  • 56
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – Wtower Jul 13 '15 at 05:40
  • @Wtower I repaired it. – NO_NAME Jul 13 '15 at 08:02
  • I'm sure self-extracting zip files or installers do *not* use Windows Resource files. Resource files aren't meant for this. Mangling multiple binaries into a single resource though is simply a bad idea that doesn't offer anything – Panagiotis Kanavos Jul 13 '15 at 08:05
  • @PanagiotisKanavos I'm trying to improve the answer and get a downvote in return. What's wrong with resources? It's typical way to put files into a windows program. If you criticize my answer, write your own proposal at least. – NO_NAME Jul 13 '15 at 08:15