-
exe generates another exe
i have to make an exe that asks for some values and write another exe.
for example:
#include<iostream.h>
void main(){
int a,b;
a=5;b=3;
cout<<(a+cool.gif;
}
my program has to write a=6 and b=9 and generate the new exe with the new values.
how can i do that?
-
Re: exe generates another exe
Why dose it have to be a new exe?
Cant you just change a and b to the new values?
Or load a and b from a textfile and edit them when the program exits to the new values
-
Re: exe generates another exe
Why don't you describe the problem you're trying to solve instead of the proposed solution. There ought to be an easier way.
-
Re: exe generates another exe
it has to built exactly this way, it has to generate from a piece of code, another exe.
-
Re: exe generates another exe
Didn't we cover this in your other thread?
-
Re: exe generates another exe
not sure what u want to archive or why it HAS to be done like the way u mention besides all the alternative ideas the gave u , but heres how it can be done:
compile the new exe u want to "generate" and declare the 2 (or more) variables as strings like:
Code:
char* a = "MY STRING 1";
char* b = "MY STRING 2";
now the tool that ask for the new values will open the file , search and replace the hardcoded string values with the users input
u can also do that with a simple HEX editor for testing
but im really curious why u need to "generate" another exe based on user input :confused:
-
Re: exe generates another exe
I've been a member of this forum for over 8 years and this is probably the most bizarre question I've ever seen posted. Coopers, to you it may seem sensible to code your solution this way but please look at your question from the point of view of another programmer. It's a bit like asking "I need to design a wheelbarrow that can make other wheelbarrows". Or "I need to design a motorbike that can ride a motorbike".
As GCDEF said earlier, tell us about the problem you're trying to solve - not about your proposed solution. There's almost certainly a more sensible solution than the one you've asked for.
Or alternatively, if it genuinely does have to be solved this particular way, please explain why. :confused:
-
Re: exe generates another exe
Quote:
Originally Posted by
John E
I've been a member of this forum for over 8 years and this is probably the most bizarre question I've ever seen posted. Coopers, to you it may seem sensible to code your solution this way but please look at your question from the point of view of another programmer. It's a bit like asking "I need to design a wheelbarrow that can make other wheelbarrows". Or "I need to design a motorbike that can ride a motorbike".
As GCDEF said earlier, tell us about the problem you're trying to solve - not about your proposed solution. There's almost certainly a more sensible solution than the one you've asked for.
Or alternatively, if it genuinely does have to be solved this particular way, please explain why. :confused:
One thing I've learned in my years in this profession is that just because somebody thinks they want something doesn't mean it's really what they want or need and the good programmers are the ones that know when they're heading down the wrong path.
-
Re: exe generates another exe
Quote:
Originally Posted by
GCDEF
One thing I've learned in my years in this profession is that just because somebody thinks they want something doesn't mean it's really what they want or need and the good programmers are the ones that know when they're heading down the wrong path.
A wise man once said, "Question the Spec."
-
Re: exe generates another exe
can i make an exe with a preinstalled complier?
i give the commands and compiles the code.
-
Re: exe generates another exe
The example that you gave above simply took some data and sent it to an external stream. But programs need more than data - they need instructions. Instructions typically form the bulk of a programming language.
If you want to use a pre-existing language (such as Java, C++, Pascal or whatever) you should be able to write a program that could call one of the many available compilers and give it a set of instructions to build into a program. But you need to have some kind of instruction language. If you don't have an actual language (and it seems that you probably don't just judging from your example) then you'll have to write an instruction set and a suitable interpreter / compiler / linker etc.
You can't produce a program just from some arbitrary data.
-
Re: exe generates another exe
some references, john_e?
how can i call a compiler and build a program after some instructions?
-
Re: exe generates another exe
What programming language will the instructions be in?
-
Re: exe generates another exe
If I were a gambling man, I'd wager that the OP plans something nefarious with this code. He's way too coy about his requirements.
-
Re: exe generates another exe
Quote:
Originally Posted by
hoxsiew
If I were a gambling man, I'd wager that the OP plans something nefarious with this code. He's way too coy about his requirements.
I agree.
-
Re: exe generates another exe
And I do too. Coopers, if you can't be a lot more specific about why you need this very unusual requirement, I don't think you'll get any more help.
-
Re: exe generates another exe
c++, john_e.
i have a good software idea, that i cannot share at the moment.
i want to find out if i can make this program by my self.
-
Re: exe generates another exe
Well, a programming IDE is essentially an exe which generates another exe by interfacing with an external compiler. There's a programming IDE built into Visual C++ but another good one is Code::Blocks
It's good because it can work with a whole bunch of different compilers and languages - and in particular, it will show you what it needs to send to the external compiler while it's working (and it also shows you what the external compiler sends back).
Download a free copy of Code::Blocks and experiment with program creation. You'll be able to see what needs to be sent to the compiler for a whole range of different compilers (although you'll need to install them first, of course). That way, you'll be able to learn how to control a compiler (which is much too big a topic for this forum).
Having said all that, I can see nothing in what you've said that convinces me about the necessity for your exe to generate another exe - unless you're planning to write your own IDE (that's what an IDE does).
Good luck but on the basis of what little you've told us, that's probably about as much help as we can give.
-
Re: exe generates another exe
thanks for the replys.
i just have to make an installer. enter the path and some options and generates the program with selected options.
donno how to do this simple task.
-
Re: exe generates another exe
A installer installs something that is already compiled.
-
Re: exe generates another exe
and how can i make an exe installer, that contains the files that has to install, and an interface for options input?
please don't give me some installers from market, i have to make one by myself in c++.
keywords please.
-
Re: exe generates another exe
Quote:
Originally Posted by
coopers
please don't give me some installers from market, i have to make one by myself in c++.
keywords please.
Since you've posted in the Visual C++ forum, why not use the installer that comes with Visual Studio?
In other words, why do you have to make one yourself?
-
Re: exe generates another exe
Quote:
why not use the installer that comes with Visual Studio?
... or you can try a free installer like InnoSetup.
-
Re: exe generates another exe
Quote:
Originally Posted by
coopers
and how can i make an exe installer, that contains the files that has to install, and an interface for options input?
please don't give me some installers from market, i have to make one by myself in c++.
keywords please.
It really isn't hard to create a dialog with some check boxes on it and it really isn't hard to copy files. Where are you stuck?
-
Re: exe generates another exe
i don't know how to include the files that has to be copied, in the exe installer.
give me some reference on the installer that comes with Visual Studio, i'll do the research, i'm not a lazy one.:D
-
Re: exe generates another exe
I suspect his problem might be how to store files so they can be retrieved from inside another file. One approach might be to use an open source archiver such as 7-zip or ARJ. These allow you to store several files inside a master file. You'd mostly need to change the user interface to give it the functionality of an installer, instead of the functionality of an archiver but because the above examples are open source, this should be relatively easy. Just watch out for licensing issues.