1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Creating Executable By Code?

Discussion in 'C' started by TinyClone, Apr 6, 2006.

  1. TinyClone

    TinyClone New Member

    Joined:
    Apr 6, 2006
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    How do you make an executable by a program? I want to have an option in my program to create an executable... how? thx in advance
     
  2. sharmila

    sharmila New Member

    Joined:
    Mar 24, 2006
    Messages:
    75
    Likes Received:
    1
    Trophy Points:
    0
    I don't know whether it helps you or not.
    There is a function called system() which is used to issue a shell command.
    int system(const char *string);
    string is the command.
    int system("cc sample.c -o sample");
    Then you will get an executable sample.
     
  3. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    734
    Likes Received:
    37
    Trophy Points:
    0
    What compiler you are using to program the code.
     
  4. TinyClone

    TinyClone New Member

    Joined:
    Apr 6, 2006
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    C++ / Visual Studio
     
  5. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    734
    Likes Received:
    37
    Trophy Points:
    0
    Compiling the code will be creating the exe in the debug/Release folder in the workspace folder.
     
  6. TinyClone

    TinyClone New Member

    Joined:
    Apr 6, 2006
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    This is what I mean:

    You have a programm, let's say it makes maze games. A user can set different settings, and then he clicks File -> Create executable. So I want to make a programm that wil make programms :).
     
  7. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    734
    Likes Received:
    37
    Trophy Points:
    0
    Thats a very complicated situations. You need to be having compiler to generate the executables but I guess your problem can be solved by a couple of ways.

    1. Allow them saving a file of your custom extension say mz and when user double clicks it it opens using your application.
    2. You save a compiled executable as a resource in the project of your VC and when user saves the data extract the binary resource to the harddisk and assign the settings accordingly into some predefined resources.
     
  8. TinyClone

    TinyClone New Member

    Joined:
    Apr 6, 2006
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    well i was thinking about have a prefab executable that opens a file of custom exenstension, but i was wondering is it was possible to create my own custom made executable. (I seen it in some programs)
     
  9. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    734
    Likes Received:
    37
    Trophy Points:
    0
    Can you give us an example of such a program.
     
  10. TinyClone

    TinyClone New Member

    Joined:
    Apr 6, 2006
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
  11. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    734
    Likes Received:
    37
    Trophy Points:
    0
    It uses the second option
    as the size of the download is onky 3.6 MB which can make us assume it does not have the compiler for creating the exe.

    Also just open the gamemaker after instalation and click on File -> Create Executable and then try running the exe. You will see the error about the resource which suggest that they have the exe as resource and when saving they inject more resource into the exe for it to run.
     
  12. TinyClone

    TinyClone New Member

    Joined:
    Apr 6, 2006
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    What you says seem pretty hard: to inject into an executable. You would have to know exeactly where everything fits in. And you can make code in gamemaker, like a script. that would be seen as resource also?
     
    Last edited: Apr 9, 2006
  13. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,292
    Likes Received:
    365
    Trophy Points:
    83
    Actually its pretty simple. There are API's to do that. See the [thread=643]sample[/thread] that reads as well as writes into an exe.
     

Share This Page