Skip to main content
GameDev.net gamedev.net
🔒 Locked

Determine absolute file paths

Started by Linc Sep 15, 2006 at 10:19 AM 2 replies 700+ views
Original Post
Linc
Linc
Hey everyone, I'm in the process of writing a custom auto-launch program for distribution on CD. It's been a while since I've written in C++, and I'm really fuzzy on the syntax. All I need to do it open a web browser with an html file from the cd, but the file is in a folder in the cd. I can access it just fine if the file's in the root of the CD, but would I access it in the folder. Here's what works when it's in the CD root: ShellExecute(NULL, "open", "index.htm",NULL, NULL,SW_SHOWNORMAL); But it doesn't work when I try something like: ShellExecute(NULL, "open", "html/index.htm",NULL, NULL,SW_SHOWNORMAL); Firefox says doesn't know how to open the address. Any ideas? Thanks in advance!
Agony
Agony
My first guess would be to try using the path "./html/index.htm" or ".\\html\\index.htm". The "." means "current directory". Otherwise, you should be able to use GetModuleFileName() to determine the full path to the currently executing exe, which I'm guessing is in the root directory of the CD. Then you can parse that to get the root folder minus the exe filename.
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas nly, and not for things themselves." - John Locke o
TheAdmiral
TheAdmiral
If you're running under Win32, the Kernel32!GetFullPathName function may be of interest to you.

Regards
Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.
Linc
Linc
Thanks for the help everyone!

".\\html\\index.htm" works!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.