What does the registry do?

Source: Internet
Author: User

Recognize and manipulate the registry
----------------------------------------------------------------------------------------
①, Introduction to the registration form:

What exactly is a registry?
The registry is actually a core database that manages the configuration of the operating parameters of the system, and it records information such as the relationship between the installation software and the running program, and the hardware configuration of the computer. It can be said that all of the hardware, software, network operations on the computer originate from the registry.
You can use the Registry Editor provided by the Regedit.exe system to manage editing the registry, which is simply an editor that is not a registry file.

All information in the registry is stored in the System.dat, User.dat file, where the System.dat file contains all the hardware and software information and User.dat contains the user information.
If two or more than two users are configured in the system, the User.dat files for each user are stored in the windows\profile\ user name directory, which are binary data files.
Modifying the registry is actually a modification of the three files above. However, we cannot make direct modifications to these binary data files, but must use the Registry Editor.

The Registry Editor is actually the graphical interface in which we view and modify registry files.

Structure of the Windows XP registry
The Windows XP registry is also organized in a tree-like form. It consists of two registry subtree: HKEY_LOCAL_MACHINE and HKEY_USERS.
However, in order to make the information in the registry easier to find, Windows XP has predefined five subdirectory trees.

Key: Root key, sub key

Key values: Key-value items, key-value types, key-value data
===================================================
②, common registry key-value types:
Other infrequently used formats are specifically shown in MSDN:
REG_BINARY: Binary data that is not processed. Most hardware component information is stored in binary and is displayed in the Registry Editor in hexadecimal format;
Reg_word: Data is represented by a number of 4 bytes long. Many device driver and service parameters are of this type and are displayed in the Registry Editor in binary, hexadecimal, or decimal format;
REG_EXPAND_SZ: variable-length data string. The data type contains variables that are determined when a program or service uses the data
REG_MULTI_SZ: Multiple strings. It contains a list of formats that can be read by the user. Items are separated by spaces, commas, or other marks;
REG_SZ: fixed-length text string;

Example of a registration:
1. System Startup item: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
2, file type registration, for the specified file type association open executable program;
===================================================
③, several root keys for the purpose of the description:

The HKEY_LOCAL_MACHINE Root key contains information about the operating system, installation software, and hardware. such as the type of computer bus, the available memory of the system, which device drivers are currently loaded, and the boot control data.
In fact, the HKEY_LOCAL_MACHINE root key holds most of the information in the registry, and the other 4 root keys are aliases for their subkeys.

The HKEY_CURRENT_USER root key contains the profile of the user who is currently logged on to the computer. Its sub-keys contain information such as environment variables, personal program groups, desktop settings, network connections, printers, and application preferences.
The computer maps the current user's information to this root key, and if the user configuration is not activated, it points to the subkey hkey_users\. DEFAULT.

The HKEY_CLASSES_ROOT root key records the correspondence between the various types of files in the system and their applications, that is, the correlation between a class of files and the application that opens the class file.
The HKEY_CLASSES_ROOT root key is a shortcut to HKEY_LOCAL_MACHINE\Software\Classes and is the largest branch of the registry, including thousands of keys and values associated with programs, files, and the definition of ActiveX classes.

The HKEY_USERS root key contains information for all users of the computer. Information such as desktop, background, Start menu program items, application shortcuts, display fonts, screen saver settings, etc. are recorded in this jianzhong with the user's personal preferences.
HKEY_CURRENT_USER is also a part of HKEY_USERS's shortcut key.

Hkey_current_config Root key contains the current configuration of the computer, such as monitors, printers and other optional external devices and their settings information.
===================================================
④, key opening and closing of the registry:

Key opening of the registry: RegOpenKey and RegOpenKeyEx
LONG WINAPI RegOpenKeyEx (
__in HKEY HKEY,
__in LPCTSTR Lpsubkey,
DWORD Uloptions,
__in Regsam samdesired,
__out Phkey Phkresult
);

Closing the registry: RegCloseKey

void Cregtestdlg::onbnclickedbtn ()
{
HKEY HKEY = NULL;
TCHAR *lpszsubkey = _t ("Software\\microsoft\\windows\\currentversion\\run");
LONG Lret = RegOpenKeyEx (HKEY_LOCAL_MACHINE, Lpszsubkey, 0, key_all_access, &hkey);
if (Lret = = ERROR_SUCCESS) {
MessageBox (_t ("Open successfully!") "));
}else{
MessageBox (_t ("Open failed!") "));
}

RegCloseKey (HKey);
}
===================================================
⑤, registry key creation and deletion:

Key creation of the registry: RegCreateKey and RegCreateKeyEx (you can also open the specified key while creating a sub-key of N-layer depth)
LONG WINAPI RegCreateKeyEx (
__in HKEY HKEY,
__in LPCTSTR Lpsubkey,
DWORD Reserved,
__in LPTSTR Lpclass,
__in DWORD dwoptions,
__in Regsam samdesired,
__in Lpsecurity_attributes lpSecurityAttributes,
__out Phkey Phkresult,
__out Lpdword lpdwdisposition
);

Key deletions for registry: Regdeletekey and Regdeletekeyex (x64)
LONG WINAPI Regdeletekey (
__in HKEY HKEY,
__in LPCTSTR Lpsubkey
);

What does the

registry do?

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.