• Advertisement
Sign in to follow this  

Getting applications directory?

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

Hello,

 

currently when I want to load resources like images etc.. in my application (VS10) I have to give it a path like this:

wstring sFilename = L"../../Editor/Frame/Cursor.png";

Now I've designed my resource loader so that it will append the "../../Editor/"-part. But still, this will only work when the directory is namend "editor". How do I get the real name of the directory the application is in (or, in that case, the upper directory because the app will be in "Editor/Debug"? Its not a big deal but it has bugged me for a while. Any idea?

Share this post


Link to post
Share on other sites
Advertisement
In Windows you can use the API function GetModuleFileName() to get the fully qualified name for the process executable. Trim off the file name to get the path.

Share this post


Link to post
Share on other sites

Though I would consider changing the project settings to your need, rather than writing your code to work around an inconvenient setup.

 

The path is already relative, so the only problem should be the difference between running from the IDE and running the binary directly.

Share this post


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

  • Advertisement