Cant find Program Files?
I am using system("start c:\\PyroSlide.pps"); to open an external power point presentation from within my program. And it works when the file is in the c root. When I move it to Program Files though,
system("start c:\\Program Files\\PyroSlide.pps");
A dialog says "Windows cannot find c:\Program" and if I remove the space, it says "Windows cannot find c:\ProgramFiles"
What am I doing wrong?
Thanks,
Matt
I am using c++ on windows xp.
system("start c:\\\"Program Files\"\\PyroSlide.pps"); // start C:\"Program Files"\PyroSlide.pps
or
system("start \"c:\\Program Files\"\\PyroSlide.pps\""); // start "C:\Program Files\PyroSlide.pps"
Directory names with spaces are a !@#$%. [smile]
The system is interpreting your command as program "start" with parameters "C:\Program" and "Files\PyroSlide.pps", using quotes helps the system interpret spaces as part of the string instead of as a argument separator. Make sense?
or
system("start \"c:\\Program Files\"\\PyroSlide.pps\""); // start "C:\Program Files\PyroSlide.pps"
Directory names with spaces are a !@#$%. [smile]
The system is interpreting your command as program "start" with parameters "C:\Program" and "Files\PyroSlide.pps", using quotes helps the system interpret spaces as part of the string instead of as a argument separator. Make sense?
When you use system, you're sending a command as if you're using the DOS-like command line. This means spaces separate one argument from another, whether they were intended to be part of a file name or not. You can fix this by putting the whole filename in quotes (remember to escape them properly in a C++ string):
EDIT: hehe, beat me to it...
system("start \"C:\\Program Files\\PyroSlide.pps\"");
EDIT: hehe, beat me to it...
In any case, it'd be better to just use ShellExecute() instead of system() to do this. Just pass the name of the file as the third argument and you don't need to worry about escaping spaces.
Quote:Original post by SiCraneOr running the correct program, or working on machines where program files isn't that directory (Such as XP-64, where it's "Program Files (x86)").
In any case, it'd be better to just use ShellExecute() instead of system() to do this. Just pass the name of the file as the third argument and you don't need to worry about escaping spaces.
EDIT: Ah, you're using start, not executing the powerpoint EXE.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement