• Advertisement
Sign in to follow this  

system call?

This topic is 4671 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

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
Advertisement
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
Sign in to follow this  

  • Advertisement