Best place to save user information for Windows XP

2019-04-10 18:49发布

I need to save a user's login information in encrypted form for this application I'm building, but I'm not sure of the best place to save the file. I don't want to save it into the program application folder as I want it per user.

So what is the best folder (or way) to save it into?

Edit: Using C++.

6条回答
啃猪蹄的小仙女
2楼-- · 2019-04-10 19:25

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

查看更多
来,给爷笑一个
3楼-- · 2019-04-10 19:27

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

查看更多
smile是对你的礼貌
4楼-- · 2019-04-10 19:28

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.

查看更多
该账号已被封号
5楼-- · 2019-04-10 19:41

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);
查看更多
对你真心纯属浪费
6楼-- · 2019-04-10 19:41

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.

查看更多
叼着烟拽天下
7楼-- · 2019-04-10 19:47

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.

查看更多
登录 后发表回答