gpt4 book ai didi

c# - 假设注册表配置单元始终相同有多安全?

转载 作者:可可西里 更新时间:2023-11-01 11:48:15 24 4
gpt4 key购买 nike

我正在编写一个允许您与注册表交互的控制台应用程序。应用程序以设置为空的字符串 path 开始。当用户键入 ls 时,我希望它列出所有注册表配置单元(因为它们当前位于本地计算机的顶层)。然而,经过一些广泛的研究后,我无法找到一种方法来获取当前机器上的所有注册表配置单元。假设这些 hive 将一直在那里有多安全?

HKEY_CLASSES_ROOT
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
HKEY_CURRENT_CONFIG

如果认为它们始终存在是不安全的,我如何动态获取它们?

(很抱歉,如果“ hive ”不是根级子项的正确术语,我对处理注册表还很陌生)

最佳答案

“标准配置单元”已记录在案,因此不会更改。

https://msdn.microsoft.com/en-us/library/windows/desktop/ms724877(v=vs.85).aspx

To open a key, an application must supply a handle to another key inthe registry that is already open. The system defines predefined keysthat are always open. Predefined keys help an application navigate inthe registry and make it possible to develop tools that allow a systemadministrator to manipulate categories of data. Applications that adddata to the registry should always work within the framework ofpredefined keys, so administrative tools can find and use the newdata.

An application can use handles to these keys as entry points to the registry. These handles are valid for all implementations of the registry, although the use of the handles may vary from platform to platform.

HKEY_CLASSES_ROOT 不是配置单元,它是其他配置单元的 View ,但它是一个预定义的键,将始终打开。

https://msdn.microsoft.com/en-us/library/windows/desktop/ms724836(v=vs.85).aspx

请参阅上面@Eser 的评论,它们也在 Microsoft.Win32.RegistryHive 枚举中。

https://msdn.microsoft.com/en-us/library/ctb3kd86(v=vs.110).aspx

关于c# - 假设注册表配置单元始终相同有多安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38286731/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com