Microsoft 是否有关于在不同 Windows 平台上存储应用程序数据与用户数据的最佳实践文档?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1507923/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does Microsoft have a best practices document regarding the storage of App Data vs User Data on different Windows Platforms?
提问by Robert Groves
When creating an application that will be targeted to many versions of Windows what is the best practice to determine where application specific data should be stored. Specifically:
在创建将针对多个版本的 Windows 的应用程序时,确定应用程序特定数据应存储在何处的最佳做法是什么。具体来说:
- Application Specific Data (e.g. app config data)
- User Specific Data/Settings
- 应用程序特定数据(例如应用程序配置数据)
- 用户特定数据/设置
I know on Windows Vista for instance there are environment variables, like %APPDATA%, that could be used, but what about Windows 7, Windows XP, Windows 98.
例如,我知道在 Windows Vista 上有可以使用的环境变量,例如 %APPDATA%,但是 Windows 7、Windows XP、Windows 98 呢。
My main question is, does Microsoft have a best practices doc for this, outlining the file system locations for the different types of data (app vs. user) and the security implications that need to be kept in mind when reading/writing to these locations?
我的主要问题是,Microsoft 是否有针对此的最佳实践文档,概述不同类型数据(应用程序与用户)的文件系统位置以及读取/写入这些位置时需要牢记的安全隐患?
I'm also interested in how this pertains to not only .NET applications (where ApplicationSettingsBase can be utilized) but also in unmanaged C/C++ applications.
我还对这不仅与 .NET 应用程序(可以使用 ApplicationSettingsBase 的地方)而且在非托管 C/C++ 应用程序中的关系感兴趣。
Thanks to Pax and Remus for both of the great answers. I've found this item as well (specific to XP):
感谢 Pax 和 Remus 提供了两个很好的答案。我也发现了这个项目(特定于 XP):
采纳答案by paxdiablo
There's a good description hereof the various CSIDL values and the folders they refer to (including a description which should hopefully tell you what you need to know).
此处对各种 CSIDL 值和它们引用的文件夹进行了很好的描述(包括希望告诉您需要了解的内容的描述)。
It also contains links to the functions you should use to retrieve these special folder paths.
它还包含指向您应该用来检索这些特殊文件夹路径的函数的链接。
Note that, as of Vista, the method has changed a little. It now uses KNOWNFOLDERID
instead of CSIDL
and the functions have changed as well. See here.
请注意,从 Vista 开始,该方法发生了一些变化。它现在使用KNOWNFOLDERID
代替,CSIDL
并且功能也发生了变化。见这里。
You can still use the older functions (at the moment) since I believe they're now just wrappers around the new ones. At some point in the future, that may change.
您仍然可以使用旧函数(目前),因为我相信它们现在只是新函数的包装器。在未来的某个时候,这可能会改变。
回答by Remus Rusanu
These are usually described in the Windows Software Logo Program (link broken). The link is to the Windows 7 logo requirements document, but similar documents exists for XP, Windows 2003, Vista and Windows 2008. In the Technical Requirements section you'll find some of the information you're looking for:
这些通常在Windows 软件徽标计划(链接已断开)中进行了描述。该链接指向 Windows 7 徽标要求文档,但也存在适用于 XP、Windows 2003、Vista 和 Windows 2008 的类似文档。在技术要求部分,您将找到您要查找的一些信息:
All application data that must be shared among users on the computer should be stored within
ProgramData
All application data exclusive to a specific user and not to be shared with other users of the computer must be stored in
Users\<username>\AppData
In “per-machine” installations, user data must be written at first run and not during the installation. This is because there is no correct user location to store data at time of installation.
必须在计算机上的用户之间共享的所有应用程序数据都应存储在
ProgramData
所有特定用户专有且不得与计算机的其他用户共享的应用程序数据必须存储在
Users\<username>\AppData
在“每台机器”安装中,用户数据必须在第一次运行时写入,而不是在安装过程中写入。这是因为在安装时没有正确的用户位置来存储数据。
EDIT:
编辑:
Windows 10 users, look for the Certification requirements for Windows Desktop Apps (Section 10)
Windows 10 用户,查找Windows 桌面应用程序的认证要求(第 10 节)