Sign in to follow this  
oneofbass

system call?

Recommended Posts

Using Visual C++ 6.0: I'm trying to program BN_CLICKED on a button control. I would like to run a separate program and exit this current program when the button is pressed. I've got something like this... void MyRunControlDlg::OnMyButton() { system("c:/somePath/otherProgram.exe"); exit(0); } This doesn't work; I just get a quick flash of a window, and the program exits. A related question: After correcting the above, how would I control how the "otherProgram.exe" starts, i.e. minimized, maximized, etc.? Thanks, Scott

Share this post


Link to post
Share on other sites
What I'm guessing is happening is that "c:/somePath/otherProgram.exe" isn't being interpreted as a proper path to the executable; either you've made a spelling error, or the shell doesn't like the /'s as path separators. Try using \ instead. Just remember to double them up so they escape properly.

If you use the CreateProcess() or ShellExecute() function instead of system() you can specify the if the spawned application is maximized or minimized. The ShellExecute() function is easier to use though.

Share this post


Link to post
Share on other sites
Thanks SiCrane!

The / versus \\ was it. I had originally tried just a single \ which produced compiler warnings about invalid escape sequence, so I switched to the foreslash. Forgot about using \\.

Well, I thumped my self on the forehead. :-o

Thanks for the help, and the ShellExecute reference.

Scott

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this