starting another program...

Started by
7 comments, last by Fruny 18 years, 8 months ago

string temp += (char) 34; // "
temp += buff; temp += (char) 92; temp+= "daisy.exe";	
temp += (char) 34;

system( temp.c_str() );



doesnt work :( i am trying to start another app from within mine and i am using the win32 platform. please help i logged the string from the code above so i know its valid
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )
Advertisement
I have no idea whether or not the system command should work at all for that, but it's not the standard way of doing that. Check out CreateProcess.
{[JohnE, Chief Architect and Senior Programmer, Twilight Dragon Media{[+++{GCC/MinGW}+++{Code::Blocks IDE}+++{wxWidgets Cross-Platform Native UI Framework}+++
oh god :(

y do they make it such hard work ?

10 params - and some of which are struct ;(

isnt there a function called popen or something?
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )
I'm pretty sure you shouldn't include the "s in the string you send to system.
And, about CreateProcess, check the examples. You can substitute most of the arguments for NULL.
aha!

sorry guys it is infact a problem with the other app.

unless its started by me double clicking it it gives an error - for example i cant open console drag the app in and press enter :(
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )
There is a function called popen...but it's for piping the output from a console command. Also not standard Win32 API (and therefore not guaranteed to correctly run your program).

Try replacing your system( ) call with:
CreateProcess(temp.c_str(), NULL, NULL, NULL, FALSE, 0, NULL, NULL, NULL, NULL);


EDIT:
This problem with the other app means either a) it can't be run from the console (which is certainly possible; using CreateProcess will still run it however), or b) it's not an app at all (it may be a shortcut, or a file designed to be opened by other apps; in that case look into ShellExecute).
{[JohnE, Chief Architect and Senior Programmer, Twilight Dragon Media{[+++{GCC/MinGW}+++{Code::Blocks IDE}+++{wxWidgets Cross-Platform Native UI Framework}+++
it is definatly an executable

*trying shellexecute*

http://leedberg.com/glsoft/daisy/index.shtml there is the app
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )
system does indeed work to start another app
but it has its limits
it returns when the other program terminates
and you don't get the fancy win32 options that you get with create processes
Quote:Original post by ErUs
unless its started by me double clicking it it gives an error - for example i cant open console drag the app in and press enter :(


What error do you get?

I suspect it is a problem of "working directory". Is your program using files with a relative path? If so, it will look for them relative to where the program was started from, not where the executable resides.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement