c++, whats that shell function again, run other apps using it?

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

Recommended Posts

Hi, a while ago I remember using a function i think was called shell to run other programs from my app, but I can't find it in any of my old source, so does anyone know what that function is called? thanks

Share on other sites
Do you mean ShellExecute()? It's a Windows API function.

Share on other sites
Hmm I don't think so, I remember it being a really simple function, with just one filename argument i think.

Share on other sites
Then you probably mean system().

Share on other sites
system()?

EDIT: just by seconds

Share on other sites
^^... if you hadn't made it a hyperlink you might have beat him...[grin]

Share on other sites
haha, yea thanks that works, although i thought i remember shell in the function name, ahwell doesnt matter now.

Thanks

Share on other sites
Hey I've got one little problem with the system function, when I put in a file with a space in its name, or in the path, it only reads to the space, and discards everything else.

There isn't any way around that is there?

Thanks

Share on other sites
system( "\"Path to a file with spaces in it\"" );

The system function just sends whatever argument you pass to the OS. You have to tell the Windows command line that the spaces in the path are not delimiters, that's why you have to put it inside quotes :)

Share on other sites
Quote:
 Original post by johnnyBravoHey I've got one little problem with the system function, when I put in a file with a space in its name, or in the path, it only reads to the space, and discards everything else.There isn't any way around that is there?

Quote it. E.g.:

system("C:\\Program Files\\Whatever\\I Like Pie.exe C:\\Documents and Settings\\Joe Smith\\A Document.doc");

becomes:

system("\"C:\\Program Files\\Whatever\\I Like Pie.exe\" \"C:\\Documents and Settings\\Joe Smith\\A Document.doc\"");

This is a limitation of the shell rather than system, AFAIK - it can't tell where the program name and each argument ends using telepathy, so it instead relies on spaces and grouping together quoted stuff.

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 10
• 12
• 10
• 11
• 13
• Forum Statistics

• Total Topics
634096
• Total Posts
3015479
×