Jump to content
  • Advertisement
Sign in to follow this  
Tolito

Detecting Application Data Directory

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

Is there a program in Windows in the System32 folder that I can call that returns the Application Data directory, or how should I go about making the program determine where to store Application Data? It is different for many versions of Windows, and with there being more versions of Windows coming up in the future, I cannot just make an array with possible directories because I would need to update that with each Windows release. Please give an informative example of how to detect exactly there the Application Data is to be stored. Thank you. :)

Share this post


Link to post
Share on other sites
Advertisement
I believe the environment variable [font=courier new,courier,monospace]%APPDATA%[/font] is set for all reasonable versions of Windows you may be targeting (from Windows 2K and up, I believe). So something like [font=courier new,courier,monospace]filepath = "%APPDATA%\\folder\\file.txt";[/font]

You shouldn't need to call a program. But if you do [font=courier new,courier,monospace]Start -> Run... -> %APPDATA%[/font] it should pop up an Explorer window with the appropriate folder open, if you're curious. Edited by Cornstalks

Share this post


Link to post
Share on other sites
Thank you for this tip. I tried this and it printed %APPDATA% just the same, however, so there must be more to it than this. Also, creating the directory will need to be done by the installer I create, correct?

Share this post


Link to post
Share on other sites
SHGetKnownFolderPath appears to be the current official way of doing this: http://msdn.microsof...8(v=vs.85).aspx

If you're creating an installer I'd highly recommend that you use a well-known installer technology rather than trying to roll your own. Visual Studio, for example, can be used to create an MSI file, and it will resolve all of this for you, as well as provide for uninstallation (and also be compatible with remote deployment via e.g. Group Policy). Edited by mhagain

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!