为什么存在 Windows 注册表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1616289/
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
Why does the Windows registry exist?
提问by justadreamer
this is more OS architecture question than programming directly, but still. Why was the Windows registry created as a completely separate subsystem for storing system/application settings? In *nix OS'es there is /etc directory which is perfectly understandable, as filesystem is a natural hierarchical way for storing settings, while Microsoft decided to create a completely outside hierarchical subsystem, which seems to be a foolish investment, why didn't they just use a filesystem hierarchy?
这是比直接编程更多的操作系统架构问题,但仍然如此。为什么 Windows 注册表被创建为一个完全独立的子系统来存储系统/应用程序设置?在 *nix 操作系统中有 /etc 目录,这是完全可以理解的,因为文件系统是存储设置的自然分层方式,而微软决定创建一个完全外部的分层子系统,这似乎是一项愚蠢的投资,为什么不他们只是使用文件系统层次结构?
回答by Kevin Montrose
- Centralized- which is useful for roaming profiles.
- Transactional- which makes it harder to smash your configuration.
- Security- You can enforce read/write with better granularity than a file (per-key/value).
- 集中- 这对漫游配置文件很有用。
- 事务性- 这使得粉碎您的配置变得更加困难。
- 安全性- 您可以以比文件(每个键/值)更好的粒度强制执行读/写。
回答by Bastien Léonard
This article discusses INI files vs registry: https://devblogs.microsoft.com/oldnewthing/20071126-00/?p=24383.
本文讨论了 INI 文件与注册表:https: //devblogs.microsoft.com/oldnewthing/20071126-00/?p =24383。
回答by JAL
So that when the binary registry gets corrupted, you'll just give up and go buy the newest version of windows for a fresh install.
因此,当二进制注册表损坏时,您只需放弃并购买最新版本的 Windows 进行全新安装。
回答by asveikau
- Each application doesn't have to reinvent a config file format
- You can easily use the registry in kernel mode code
- 每个应用程序不必重新发明配置文件格式
- 您可以轻松地在内核模式代码中使用注册表
As mentioned in the Old New Thing article cited by Bastien:
正如 Bastien 引用的 Old New Thing 文章中提到的:
- The system can handle concurrency issues for you
- You can ACL registry keys
- 系统可以为你处理并发问题
- 您可以使用 ACL 注册表项
I would also mention that many *nix frameworks have reinvented the registry... Like gconfd on GNOME.
我还要提到许多 *nix 框架已经重新发明了注册表......就像 GNOME 上的 gconfd。
回答by peterchen
Also, file system granularity: one cluster for each value is a bit to much, so you need to make a tradeoff where the file system ends and the settings file starts. That of course doesn't give you a consistent API. So why not pull all settings into a few key files, and give you a consistent API to access it? BAM - registry.
此外,文件系统粒度:每个值一个集群有点太多,因此您需要在文件系统结束和设置文件开始的位置进行权衡。这当然不会为您提供一致的 API。那么为什么不把所有设置都放到几个关键文件中,并为您提供一个一致的 API 来访问它呢?BAM - 注册表。
(And since MS generally considers API more importantthan format, it's no surprise the files are opaque)
(而且由于 MS 通常认为 API 比格式更重要,因此文件不透明也就不足为奇了)
[Raymond Chen voice]Remember, it was designed for computers where 4MB of RAM was plenty.[/Raymond Chen voice]
[Raymond Chen 语音]记住,它是为 4MB 内存足够的计算机设计的。[/Raymond Chen 语音]
回答by yogman
They did it, I believe, to support a separate setting for each login user. In Unix, there's a concept of home directory, while none in Windows.
我相信,他们这样做是为了支持每个登录用户的单独设置。在 Unix 中,有一个主目录的概念,而在 Windows 中没有。
回答by Gabb0
The idea is to have all settings for all programs stored in one single place instead of having them spread all over your disk.
这个想法是将所有程序的所有设置都存储在一个地方,而不是将它们散布在整个磁盘上。
回答by Rob
For starters, it's quicker to read and write to the registry during the course of a user session.
对于初学者来说,在用户会话过程中读取和写入注册表会更快。
回答by srini.venigalla
It created a single point entry for the entire system's application configuration control. It would have been a nice usecase for an embedded network database (e.g. Raima used by Rational) or a text database (Bernstein's cdb).
它为整个系统的应用程序配置控制创建了一个单点入口。对于嵌入式网络数据库(例如 Rational 使用的 Raima)或文本数据库(Bernstein 的 cdb)来说,这将是一个很好的用例。