The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => The Orphanage => Topic started by: xanatose on April 05, 2009, 02:38:19 PM

Title: QUESTION: About win32 directories.
Post by: xanatose on April 05, 2009, 02:38:19 PM
In which directory should an application store its configuration files?

In Vista I see:
\Users\UserName\AppData\Local
\Users\UserName\AppData\LocalLow
\Users\UserName\AppData\Roaming

But I have no idea what is the difference on each one.Nor do I know what is the correct way to get them from a program. Are they on the registry or is there an api function to get those directories?

Where can I get this information not only for vista, but for XP.

Title: Re: QUESTION: About win32 directories.
Post by: Jimg on April 05, 2009, 03:03:07 PM
None of the above.

An application should store ALL it's files in it own folder.

A user should be able to pick up that folder and plop it on another drive or another computer and have it run flawlessly.

In other words, use an ini file in the apps folder, not the registry.

If you want to support multiple users, make an ini file section or a separate ini file for each user.

That's the way it SHOULD work, despite microsofts insanity.

Just my two cents worth.
Title: Re: QUESTION: About win32 directories.
Post by: BlackVortex on April 05, 2009, 03:41:20 PM
Portable is generally better for smaller apps. But if you want to save setting in the user's documents/applications dir, there are some APIs to get them. Then you essentially have multi-user functionality.

I've never used it, but a quick msdn search makes me think SHGetFolderPath  is the right for the job.
Title: Re: QUESTION: About win32 directories.
Post by: Tedd on April 05, 2009, 03:57:51 PM
SHGetFolderPath (http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx) allows you to get the correct locations for various folders, which differ on each version of windows. You can select which is the most appropriate from http://msdn.microsoft.com/en-us/library/bb762494(VS.85).aspx

That said, for program settings, you're supposed to use the registry - "HKCU\Software\Company\Application\" is the preferred location.
Title: Re: QUESTION: About win32 directories.
Post by: Jimg on April 05, 2009, 04:26:58 PM
And you're supposed to use .net and C++
Title: Re: QUESTION: About win32 directories.
Post by: BlackVortex on April 05, 2009, 04:35:42 PM
For smaller/portable apps, it's better to keep different ini files named after the current username. (in the current folder)

So you just check for username.ini on startup or create it if it doesn't exist. And users can easily bakup their settings,restore to the defaults by deleting the ini, change the ini manually if needed, share settings between them easily etc etc.
Title: Re: QUESTION: About win32 directories.
Post by: xanatose on April 05, 2009, 06:25:19 PM
Thank you all.
Title: Re: QUESTION: About win32 directories.
Post by: Vortex on April 05, 2009, 07:30:34 PM
Hi xanatose,

You can also use environment variables to specify those directories.  An example :

%appdata% = C:\Documents and Settings\UserName\Application Data