Jump to content

  • Log In with Google      Sign In   
  • Create Account

Detecting Application Data Directory


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Tolito   Members   -  Reputation: 256

Like
0Likes
Like

Posted 23 July 2012 - 07:45 PM

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. :)

Sponsor:

#2 Cornstalks   Crossbones+   -  Reputation: 6991

Like
2Likes
Like

Posted 23 July 2012 - 07:50 PM

I believe the environment variable %APPDATA% is set for all reasonable versions of Windows you may be targeting (from Windows 2K and up, I believe). So something like filepath = "%APPDATA%\\folder\\file.txt";

You shouldn't need to call a program. But if you do Start -> Run... -> %APPDATA% it should pop up an Explorer window with the appropriate folder open, if you're curious.

Edited by Cornstalks, 23 July 2012 - 07:51 PM.

[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#3 Tolito   Members   -  Reputation: 256

Like
0Likes
Like

Posted 23 July 2012 - 08:10 PM

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?

#4 Matt-D   Crossbones+   -  Reputation: 1469

Like
1Likes
Like

Posted 23 July 2012 - 08:19 PM

Although it's C++, perhaps it will be of some use: http://stackoverflow...windows-using-c

If you have access to the registry, you can read HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\AppData, as documented here: http://technet.micro...y/cc962614.aspx

Edited by Matt-D, 23 July 2012 - 08:19 PM.


#5 mhagain   Crossbones+   -  Reputation: 8278

Like
3Likes
Like

Posted 23 July 2012 - 08:37 PM

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, 23 July 2012 - 08:38 PM.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#6 Tolito   Members   -  Reputation: 256

Like
0Likes
Like

Posted 23 July 2012 - 10:28 PM

This is exactly what I needed. Thank you all! :D




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS