Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the primary keys for operating the registry in C #

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what are the primary keys to operate the registry in C#". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Five primary keys for operating the registry in C #: the registry of the Windows operating system contains a lot of configuration about the operation of the computer. When we open the registry, we can see that the registry is organized according to a tree structure similar to a directory, in which the second-level directory contains five predefined primary keys: HKEY_CLASSES_ROOT,HKEY_CURRENT_USER,HKEY_LOCAL_MACHINE,HKEY_USERS,HKEY_CURRENT_CONFIG.

Let's explain the five primary keys for operating the registry in C # respectively.

The HKEY_CLASSES_ROOT of the five primary keys that operate the registry in ◆ C#

The primary key contains the extension of the file and the associated information of the application, as well as the information used by Window Shell and OLE to store the registry. The subkeys under this primary key, which are mapped from HKEY_LCCAL_MACHINE\ SOFTWARE\ Classes, determine how such files and their icons are displayed in WINDOWS.

The HKEY_CURRENT_USER of the five primary keys that operate the registry in ◆ C#

The primary key contains information about the current user, such as user window information, desktop settings, etc.

The HKEY_LOCAL_MACHINE primary key of the five primary keys that operate the registry in ◆ C#

Contains installation and configuration information for computer software and hardware, which is available to all users

HKEY_USERS, the five primary keys for operating the registry in ◆ C#

The primary key records the setting information of the current user, and every time the user logs in to the system, a subkey with the same login name is generated under the primary key, which stores the current user's desktop settings, background bitmap, keyboard shortcuts, font and other information. General applications do not access the primary key directly, but access it through the primary key HKEY_CURRENT_USER.

HKEY_CURRENT_CONFIG, the five primary keys for operating the registry in ◆ C#

This key holds the configuration information of the current hardware of the computer, which can be changed according to the type of network currently connected or the installation of hardware driver software.

C # also supports editing of the registry, and the .NET Framework provides two classes in the Microsoft.Win32 namespace to manipulate the registry: Registry and RegistryKey. Both classes are sealed and are not allowed to be inherited. Let's introduce these two classes respectively.

The Registry class provides seven common static fields, each representing seven basic primary keys (two of which are not in the XP system, so I won't cover them here):

Registry.ClassesRoot,Registry.CurrentUser,Registry.LocalMachine,Registry.Users,Registry.CurrentConfig . Which keys do they correspond to? I think you will know at a glance.

Methods for manipulating the registry are provided in the RegistryKey class. It is important to note that manipulating the registry must comply with system permissions, otherwise an error will be thrown.

This is the end of the content of "what are the primary keys to operate the registry in C#". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report