windows - 说你不应该写入 Program Files 区域的指南在哪里?

标签 windows

关于 SO 的许多问题都说“Windows 开发人员指南”或“Windows 设计指南”说你不应该将临时或程序数据写入程序文件区域,但据我所知,它们都没有实际链接到一份说明同样多的文件。搜索 MSDN 没有任何结果。 Windows 将使该区域成为只读区域,因此它可以由操作系统强制执行,但这并不意味着开发人员无论如何都不会尝试在那里写入(例如,在向前移植旧的、XP 和更早版本的程序时。)

我意识到在 Windows 开发这么晚的时候问这个问题似乎很奇怪(因为,正如下面的评论者所指出的那样,操作系统已经强制执行了十多年),但有时需要一份这样说明的文档来满足人们。

考虑到这一点,Microsoft 是否发布了声明我们不应将应用程序数据写入 Program Files 区域的文档,如果有,它在哪里?

最佳答案

来自 Windows 7 客户端软件 Logo 计划的技术要求:

Install to the correct folders by default

Users should have a consistent and secure experience with the default installation location of files, while maintaining the option to install an application to the location they choose. It is also necessary to store application data in the correct location to allow several people to use the same computer without corrupting or overwriting each other's data and settings.


Windows provides specific locations in the file system to store programs and software components, shared application data, and application data specific to a user:

  • Applications should be installed to the Program Files folder by default. User data or application data must never be stored in this location because of the security permissions configured for this folder (emphasis added)
  • 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
  • Never write directly to the "Windows" directory and or subdirectories. Use the correct methods for installing files, such as fonts or drivers
  • 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. Attempts by an application to modify default association behaviors at a machine level after installation will be unsuccessful. Instead, defaults must be claimed on a per-user level, which prevents multiple users from overwriting each other's defaults.

而且我非常确定,对于 NT 系列的每个 Windows 版本,追溯到 Windows NT 4 甚至更早版本,都有类似的东西。


另见 this question .


编辑:此帖子中指向 Windows 7 Logo 程序的原始链接已不存在。在这里您可以找到 Certification requirements for Windows Desktop Apps 的当前链接。 .请参阅第 10 节,默认情况下应用必须安装到正确的文件夹

关于windows - 说你不应该写入 Program Files 区域的指南在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13163611/

相关文章:

c++ - WriteConsoleOutputCharacter 使控制台应用程序崩溃

c - 使用 C 中名为 getfullpathname() 的函数解析路径?

windows - 非 TLS 1.3 Azure 存储库上的 TLS1.3 错误 'Wrong version number'

linux - pdf = rs.getBytes ("pdf");它在 Windows 操作系统中不起作用。从 postgres bytea 字段读取二进制数据的替代方法是什么

python - django操作系统错误: no library called "cairo" was found on windows

windows - Windows 8.1 后 WinAPI 弃用

windows - 我的 Windows 应用程序是否需要使用受信任的证书进行签名?

java - 触发在 Windows 上运行的 1.5 JVM 的堆转储

windows - 等效于 ps -A | Windows 中的 grep -c 进程?

linux - 在 windows 和 linux 中分发项目的最佳方法是什么?