954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C++ Ressource

Hello, i have a little big problem.

I have an application that needs to 'download' two exe files but i don't want to make internet connections and ...
So my application verifies the system time and should 'extract' the .exe for x64 or x86.
But i don't know how to 'embed' that 2 exes in my app.

Ex :

I have APP.EXE

and 164.exe
and 286.exe

I want an example for doing that :

When i start app.exe, my applications 'extracts' 164.exe from himself and outputs that file near him.

Please, help !

zekstein
Light Poster
33 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

You can use something like this to turn the binaries into code, then write them out using the standard library.

If you want to get fancy with the linker, you can also link them to your application directly .

gusano79
Posting Pro
519 posts since May 2004
Reputation Points: 182
Solved Threads: 77
 

Oh goog ... i like that bin2h.
But how to transform that code ( ex myapp.h ) into .exe near my app. ?

zekstein
Light Poster
33 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

Sorry for double :
I tried :


std::ofstream file;
file.open("ADRIAN2.EXE");

file.write( (const char*)nosize, nosize_size);
file.close();

But .... if i open with notepad the original file ( from that i obtined that .h ) and the outputed file .. they are the same.
But if i open the outputed file it is closing when i start it :|

If i make an .bat, write ADRIAN2.exe then pause ...
The console outputs :

''

C:\Users\Adrian\Documents\Visual Studio 2010\Projects\ZekProject\Release>ADRIAN2

This program cannot be run in DOS mode.

C:\Users\Adrian\DOCUME~1\VISUAL~1\Projects\ZEKPRO~1\Release>pause 1>null

''

zekstein
Light Poster
33 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 
if i open with notepad the original file ( from that i obtined that .h ) and the outputed file .. they are the same. But if i open the outputed file it is closing when i start it :|

If they're really the same, there shouldn't be any difference, so something must have changed.I tried :

std::ofstream file;
file.open("ADRIAN2.EXE");

file.write( (const char*)nosize, nosize_size);
file.close();

Hm. Have you tried opening the file in binary mode ? You'll definitely want to do that with an executable.

gusano79
Posting Pro
519 posts since May 2004
Reputation Points: 182
Solved Threads: 77
 

Milllion of thanks ! Opening file in binary mod solved !
Thank you soo much !


[solved]

zekstein
Light Poster
33 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You