Best place to save user information for Windows XP and Vista applications

◇◆丶佛笑我妖孽 提交于 2019-12-04 11:58:59

Seems like C:\Documents and Settings\%username%\Local Settings\Application Data may be the appropriate place according to Wikipedia. The article says this location is used for "User-specific and computer-specific application settings".

Edit: Cruizer pointed out in the comments (I'd reply there but I can't comment yet) that in Vista it is C:\Users\%username% and that it shouldn't be hard-coded. Thanks.

Use the Data Protection API (DPAPI) - a part of the CryptoAPI in XP and Vista. Here's a good overview of DPAPI - http://msdn.microsoft.com/en-us/library/ms995355.aspx

Lodle

Yeah, local application path looks like a winner.

I found this article in MSDN to get it in C++: http://msdn.microsoft.com/en-us/library/bb762494.aspx

Example:

char localAppPath[MAX_PATH];
SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, localAppPath);

are you using .NET? how about IsolatedStorage? That way you wouldn't have to worry about the directory location, it'll just be there...

User information should always go in some sub directory in %HOMEDRIVE%%HOMEPATH% (Which maps to the users home directory). No exceptions. A good place for application specific settings per user is a sub directory inside %APPDATA%. This maps to: "%HOMEDRIVE%%HOMEPATH%\Application Data" on XP and to: " %HOMEDRIVE%%HOMEPATH%\AppData\Roaming" on Vista.

If you are using .NET to get special folders you can use

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

or

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

for the non-roaming version.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!