A simple read-write registry instance

Source: Internet
Author: User

One, Description:

The registry is an important part of Windows, and the registry records a large amount of information about computer hardware and software. The value in the registry is identified by its name. The value name consists of the same characters as the key name. The value itself can be a string, binary data, or a 32-bit unsigned value. Here we mainly use the following techniques:

(a) A predefined registry key. The registry contains several predefined keys:

HKEY_LOCAL_MACHINE contains entries that describe the computer and its configuration. This includes information about the processor, system board, memory, and installed software and hardware.

HKEY_CLASSES_ROOT is a support key for information related to document types and ole\com. This key is the subordinate key of the HKEY_LOCAL_MACHINE.

HKEY_USERS is used as the default user preference setting and as the preferred setting for individual users.

Hkey_classes_user is the information for the current (logged-on) user.

Hkey_current_config contains information about the current system configuration.

There is another, generally will not appear, only the configured LAN will have.

(ii), CRegKey class and the main use and function description

Required header file: atlbase.h

Common functions☆ function to open a key: RegOpenKeyEx
function definition: LONG RegOpenKeyEx (hkey hkey,//a handle to a key that is already open, or directly a few of these root keys
LPCTSTR lpsubkey,//The address of the name of the subkey to be opened
DWORD uloptions,//reserved value, must be 0
Regsam samdesired,//open mode, such as read or write
Phkey the handle of the Open subkey returned by phkresult//
);
☆ Query A key value: RegQueryValueEx
function definition: LONG RegQueryValueEx (hkey hkey,//The handle of the key to query
LPCTSTR lpvaluename,//The name of the key value to query
Lpdword lpreserved,//Reserved value
Lpdword lptype,//The type of data to query
LPBYTE lpdata,//data for the query to be returned
Lpdword lpcbdata//The length of the preset data
);
☆ Set a key value RegSetValueEx
function definition: LONG RegSetValueEx (hkey hkey,//The handle of the key to be set
LPCTSTR lpvaluename,//The name of the key value to access
Lpdword lpreserved,//Reserved value
DWORD dwtype,//The type of data to set
Const BYTE *lpdata,//The health value to set
The length of the DWORD cbdata//data
);

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.