C # operate the Registry

Source: Internet
Author: User

1. What is the registry?
A tree table that stores the configuration information of the computer running mode. Including Windows operating system configuration information and applicationsProgramConfiguration information, dedicated user device configuration information, Environment configuration information, and so on. In addition, the Registry also contains security, network management, and other configuration information in the Windows operating system and Windows operating system.

2. registry editing tool

• Regedit: it is available in all Windows versions. It is the standard version from Windows 95.
• Regedt32: This is available in WINNT and win2000. It is not as user-friendly as regedit, but can access security information that Regedit cannot access.

3. Primary Key, subkey, and key value

• Primary Key: Items displayed on the left of the Registry Editor
• Subkey: the subkey of the primary key, which is the subkey of the primary key.
• Key Value: a primary key can have one or more values. The value name is a key value.

4. Key Value Type

• String (reg_sz)
• Binary (reg_binay)
• Dual-word (REG_DWORD)
• Winnt also includes the following extended string values-extended string values (reg_expand_sz)-Multi-string values (reg_multi_sz)

5. Seven pre-defined primary keys in the Windows Registry

• Hkey_classes_root
• HKEY_CURRENT_USER
• HKEY_LOCAL_MACHINE
• HKEY_USERS
• Hkey_current_config
• Hkey_dyn_data
• Hkey_performance_data

6. Seven public static domains are provided, representing 7 in the Registry respectively.
Basic primary key:
• Registry. classesroot: corresponding to the hkey_classes_root primary key
• Registry. currentuser: primary key corresponding to HKEY_CURRENT_USER
• Registry. localmachine: corresponds to the hkey _ LOCAL_MACHINE primary key
• Registry. Users: corresponding to the HKEY_USERS primary key
• Registry. currentconfig: primary key corresponding to hkey1_current_config
• Registry. dyndta: corresponding to the hkey_dyn_data primary key
• Registry. performancedata: corresponding to the hkey _ performance_data primary key

7. Registry and registrykey
They are all sealed classes, that is, they cannot be inherited. The registrykey instance represents a registry key. This class can be used to browse subkeys, create new keys, read or modify values in keys. It can be used to complete all operations on the registry.
Registry is a class that cannot be instantiated. It only provides registrykey instances that represent the grading key.

8.CodeExample:

Code
Using System;
Using System. Collections. Generic;
Using System. text;
Using Microsoft. Win32;

Namespace Leleapplication1
{
Class Program
{
Static   Void Main ( String [] ARGs)
{
// Locate primary key
Registrykey key = Registry. currentuser;
// Create regetry key
Registrykey key1 = Key. createsubkey ( @" Software \ regetrydemo " );
Key1.setvalue ( " Nofind " , " 1 " );
Key1.setvalue ( " No money " , " 2 " );
Key1.close ();
// Read regetry key
Registrykey key2 = Key. opensubkey ( @" Software \ regetrydemo " );
Foreach ( String S In Key2.getvaluenames ())
{
Console. writeline ( " Name: "   + S +   " Value: "   + key2.getvalue (s);
}< br> console. read ();
}< BR >}< br>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.