Jump to content
  • Advertisement
Sign in to follow this  
WarGames

Running an application from within another application - C++

This topic is 4349 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've always wondered- how do you run another application from inside an application (i.e. what's the command from application1 to run application2?). Also, if you have an answer, could you also include how to send it parameters? Thanks :)

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure if it can be ran from within it, rather than starting a seperate application.

C++ allows for certain lamguages to be embdedded into its code, which si read from a file, and ran right then and there. Trhe advantage to this, is might whaty ou already thought; breaking up a large application by including seperate applications/scripts that can be changed/modified without recompiling the whole huge project.

Some languages are Lua, Ruby, I believe LISP and Python(not sure).

Share this post


Link to post
Share on other sites
the answer to this depends entirely on the platform and environment you are using, as there are different ways to accomplish this which may not be feasible in some contexts-if you are interested in the Win32 solution, make sure to check out the MSDN documentation for "ShellExecute", for *nix development, you'll want to look into functions such as "exec".

However, in general one of the most portable solutions is to simply use the "system" call:



#include <cstdio> //not necessarily required-depends on your compiler/OS etc
#include <cstdlib>

int main()
{
using namespace std;
char *cmd="dir /p"; // simply add parameters to the string

system(cmd);

return 0;
}



HTH

Share this post


Link to post
Share on other sites
So the "dir" part is the application itself, and then just list the paramaters, correct?

I forgot to mention that I'm using Windows, although the application I want to run is a console app that I'm using for internet-related tasks.

Thanks for the quick response. I really appreciate it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!