Click here to Skip to main content
15,891,841 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Is there a way of creating self-exetractor by already created program?
I found a great method of making self-extractor
Adding and extracting binary resources[^]
but it puts files into .exe only when compiling, while I need it to be a function, which will be done multiple times, and it will be done with new files each time.
I need a function of a program that would put / store / write some files to another .exe program, from which I could extract those files later by executing it. I care about putting those files to one self-extractor more than compression.

So, shortly: How do I create a program which creates programs with some files and with some executable code in it?

What I have tried:

I suppose it requires some experience in creating development tools themselves, so maybe there is a way of borrowing something from, say, MS Visual C++?

Maybe it is possible with zlib library (since its programs does the part where you put files to one file, but again, I want those files to be in exe.)?
Posted
Updated 27-Jun-16 6:27am
v9
Comments
Mohibur Rashid 26-Jun-16 19:31pm    
Try a better architecture
Sergey Alexandrovich Kryukov 26-Jun-16 23:27pm    
Golden words. The next comment, by enhzflep is also very good, please see.
—SA
Brackets 27-Jun-16 6:18am    
If I was aware of better architecture, I wouldn't be here to ask the question, thank you.
enhzflep 26-Jun-16 20:31pm    
This sounds a lot like an X/Y problem to me.

An X/Y problem arises when you need to complete a task, X. You imagine that the best way to solve this is to do Y. So, you then go online to get help and ask questions about achieving Y.

Unfortunately, had people known you were trying to achieve X instead of Y, they'd have given you entirely different advice.

So, with all that said - what are you ultimately trying to achieve? Remember, compression is the tool you imagine to be necessary, not the destination itself.
Sergey Alexandrovich Kryukov 26-Jun-16 23:29pm    
You described the whole syndrome, very precisely. Too bad so many inquirers don't understand it; and it's pretty hard to explain to such people; and they are not only the beginners. It's a big thing: to identify a problem which should not be solved, instead of solving it.

One problem is that sometimes it's not even X/Y, but A/.../X/Y, and perhaps even X should not be solved. I always try to ask the inquirer: what is A, but they rarely answer.

—SA

 
Share this answer
 
Comments
Brackets 27-Jun-16 4:56am    
I don't need to create zip archive. I don't need it to be .zip, but to be .exe. I need to create a program like WinZip, just without compression thing and converting from .exe to .zip. I assume that is just simpler version of zip. The part where running program puts all files together to itself/to another program is the only part I lack.
Richard MacCutchan 27-Jun-16 9:41am    
Sorry but I do not understand what that means. A self extracting zip archive is an executable.
Brackets 27-Jun-16 9:51am    
But the way it's being created is not okay for me. You can only put files into such self-executable when you're compiling it. I need the code to do that. Putting files to self-extractor is the function of a program I need.
Richard MacCutchan 27-Jun-16 10:05am    
Then you will need to write your own program to do it.
Brackets 27-Jun-16 10:14am    
Yeah. Any advices how do I do that?
Actually, yes you DO need to create a .ZIP file.

A self-extracting executable is nothing more than an .EXE file with a .ZIP file appended to the end of it, something like this:
C:\>COPY SelfExtractor.exe + MyZipFile.zip  SelfExtractingZip.exe

You need to write your self extractor to look at the file it was launched from and search for the .ZIP header in that file. From there it's your own implementation of unpacking the archive based on a stream that you open and seek to the beginning of the .ZIP file portion of your .EXE.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900