CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    Join Date
    Nov 2009
    Posts
    19

    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?

  2. #2
    Join Date
    Nov 2009
    Posts
    4

    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

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    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.

  4. #4
    Join Date
    Nov 2009
    Posts
    19

    Re: exe generates another exe

    it has to built exactly this way, it has to generate from a piece of code, another exe.

  5. #5
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: exe generates another exe

    Didn't we cover this in your other thread?

  6. #6
    Join Date
    May 2006
    Location
    beyond the pillars of hercules
    Posts
    295

    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
    Last edited by Cpp_Noob; November 8th, 2009 at 05:00 PM.

  7. #7
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    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.
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  8. #8
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: exe generates another exe

    Quote Originally Posted by John E View Post
    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.
    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.

  9. #9
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: exe generates another exe

    Quote Originally Posted by GCDEF View Post
    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."

  10. #10
    Join Date
    Nov 2009
    Posts
    19

    Re: exe generates another exe

    can i make an exe with a preinstalled complier?

    i give the commands and compiles the code.

  11. #11
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    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.
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  12. #12
    Join Date
    Nov 2009
    Posts
    19

    Re: exe generates another exe

    some references, john_e?

    how can i call a compiler and build a program after some instructions?

  13. #13
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: exe generates another exe

    What programming language will the instructions be in?
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  14. #14
    Join Date
    Feb 2005
    Posts
    2,160

    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.

  15. #15
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: exe generates another exe

    Quote Originally Posted by hoxsiew View Post
    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.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured