Jump to content
  • Advertisement
Sign in to follow this  
Code Is Your Friend

Cant find Program Files?

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

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.

Share this post


Link to post
Share on other sites
Advertisement
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?

Share this post


Link to post
Share on other sites
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):
system("start \"C:\\Program Files\\PyroSlide.pps\"");


EDIT: hehe, beat me to it...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
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.
Or 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)").

EDIT: Ah, you're using start, not executing the powerpoint EXE.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!