Registry understanding and C ++ operation registry example (to be continued)

Source: Internet
Author: User

 

C ++RegistryOperation

1. Understanding of registry Composition

AndXPFile Management on the system is similar.

(1)Root Key: Total5.

Hkey_classes_root,HKEY_CURRENT_USER,

HKEY_LOCAL_MACHINE,HKEY_USERS,Hkey_current_config

It is equivalent to five disks.

(2)Zi Jian: You can have multiple key-value items and multiple sub-Keys.

For example:HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control

Below isAGP,Arbiters. AndCurrentuser,SystemBootdevice and other key-value items.

The child key is equivalent to a folder with Multiple folders and files.

(3) Key-value items:3Components. Name, type, and data value.

Key-value items are equivalent to one file.

 

2,Open/CloseRegistry:

Regopenkeyex (

Hkey ,//Parent key handle

Lpsubkey ,//Child key handle

Dwoption ,//System reserved, specified0

Samdesired ,//Open permission

Phkresult ,//Return opening handle

)

 

// Open the key

Hkey key ;//Store returned valuesKeyMedium

Lpctstr DATA = _ T ("SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run ");

If (regopenkeyex (HKEY_LOCAL_MACHINE, Data, 0, key_all_access, & Key) = error_success)

{;}

 

//Close key

Regclosekey (key );

 

3View the basic information of the key value and its sub-keys (equivalent to opening a directory)

Regqueryinfokey

Obtains the number of child keys, the longest name length in the Child key, the longest String Length in the Child key,

The number of key values, the longest name length in the key value, and the longest String Length in the key value.

 

4. traverse the child key information of a key

Regenumkeyex

 

5, Traverse the key value information of a key

Regenumvalue

 

Query a specified key value: regqueryvalueex ()

Set a specified key value: regsetvalueex ()

 

(To be continued)

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.