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)