Data
The registry is made up of keys (or "Keys"), sub-keys (subkeys) and value items. A key is a folder in a branch, and a subkey is a subfolder in that folder, and the subkey is also a key. A value entry is the current definition of a key, consisting of a name, a data type, and an assigned value. A key can have one or more values , each value has a different name, and if the name of a value is empty, the value is the default value for that key.
Data type
The Registry has the following four types of data:
Display type (in editor) data type description
REG_SZ string Literal string
REG_MULTI_SZ string with multiple literal values
REG_BINARY binary number binary value, shown in hexadecimal.
REG_DWORD Double Word a 32-bit binary value that is displayed as a 8-bit hexadecimal value.
A brief introduction to each primary key
- HKEY_LOCAL_MACHINE is a processing key for display control systems and software. The HKLM key holds the computer's system information. It includes all software settings on the network and hardware.
- HKEY_CLASSES_ROOT is the item in the system that controls all data files.
- HKEY_USERS Enter information for the default user and the currently logged on user into the Registry Editor
- HKEY_CURRENT_USER contains the same information listed in the HKEY_USERS security identification.
- Hkey_current_config includes the details of all the existing configuration files in the system. Hkey_current_config allows software and device driver programmers to easily update the registry without involving multiple configuration file information. The same data and any registry changes in the HKEY_LOCAL_MACHINE.
--------------------------------------------------------------------------------------------------------------- ------------------------------------
Reference Page http://www.cnblogs.com/kzloser/archive/2012/11/07/2758404.html
Add boot loader
#include <iostream>#include<stdio.h>#include<stdlib.h>#include<string.h>#include<strings.h>#include<windows.h>#include<cstdlib>using namespacestd;intMain () {HKEY HKEY; LPCTSTR Lprun="Software\\microsoft\\windows\\currentversion\\run"; DWORD State,dwtype,sizebuff; LongLret; Charrebuff[Ten] = {0}; cout<<"enter 0 or 1. Perform the operation. 1 Insert 0 Delete"<<Endl; intOperatornum; CIN>>Operatornum; cout<<operatorNum<<Endl; cout<<"======================================================================="<<Endl;/**long RegCreateKeyEx (HKEY HKEY,//primary Key name LPCWSTR lpsubkey,//subkey name or path DWORD Reserved,//0 reserved field, default set of 0 LPWStr LpC Lass,//general set to null DWORD dwoptions,//Some options for the key you established, can be these values: Reg_option_non_volatile,reg_option_volatile,reg_option_ Backup_restore The first one is the default. You can use the first one as a general rule. Regsam samdesired,//Set your access rights to this key you have established ignored. Set to zero-ensure compatibility with the future versions of Windows Mobile. Lpsecurity_attributes lpsecurityattributes,//general set to null Phkey Phkresult,//return handle to new registry key Lpdword lpdwdisposition//used to view Whether to open an existing key or a new key); Explanation: Opens the specified key or subkey. If the key you want to open does not exist, this function will attempt to establish it. When you create or open a key for the registry, you need to specify access permissions, which require access to the first level. The default permissions are key_all_access permissions. There are also key_create_link create character chain permissions, Key_create_sub_key Create subkey permissions, Key_execute read key permissions, key_notify get permission to modify key notifications, Key_query_value query key value permissions , key_set_value the permission to set the data value. Note You cannot create a key at the root level, only predefined keys at the root of the registry. For specific use, please check the online manual. *///https://msdn.microsoft.com/zh-cn/aa911940 if(operatornum==1) {Lret= RegCreateKeyEx (Hkey_current_user,lprun,0Null0,0,null,&hkey,&State ); if(Lret = =error_success) { if(state = =reg_created_new_key) cout<<"Create OK"<<Endl; RegCloseKey (HKey); }Else{cout<<"Create fail"<<Endl; }/*LONG RegOpenKeyEx (HKEY HKEY, Lpcwstr Lpsubkey, DWORD uloptions,//reserved. Set to zero. reserved field, default setting is 0 Regsam samdesired,//not supported. Set to zero. Phkey Phkresult//Pointer to a variable so receives a handle to the opened key. When you are no longer need the returned handle, call the RegCloseKey function to close it.);*/ /*LONG RegSetValueEx (HKEY HKEY, lpcwstr lpvaluename,//input DWORD reserved,//reserved. Must is set to zero. DWORD Dwtype,//type of information to is stored as the Value Data const byte* Lpdata,//[in] Pointer to a buffer that co Ntains the data to is stored with the specified value name. DWORD Cbdata//[in] Size, in bytes, of the information pointed to by Lpdata. If The data is of type REG_SZ, REG_EXPAND_SZ, or REG_MULTI_SZ, this parameter must include the size of the terminating nul L character. The maximum size of data allowed is 4 KB. );*/Lret= RegOpenKeyEx (HKEY_CURRENT_USER, Lprun,0, Key_write, &HKey); if(Lret = =error_success) {cout<<"Open OK"<<Endl; //RegSetValueEx (HKey, "Mgtest", 0,REG_SZ, (BYTE *) "Success", 10); //RegSetValueEx (HKey, "Mgtest", 0,REG_SZ, (BYTE *) "C:\\windows\\system32\\notepad.exe", strlen ("c:\\windows\\ System32\\notepad.exe "); Longtemp= RegSetValueEx (HKey,"mgtest",0, REG_SZ, (BYTE *) "c:\\windows\\system32\\notepad.exe" , strlen ( "c:\\windows\\system32\\notepad.exe" )*2); if(temp!=error_success) {cout<<"Set fail"<<Endl; }Else{cout<<"set OK"<<Endl; } regclosekey (HKey); }Else{cout<<"Open Fail"<<Endl; } }Else{Lret= RegOpenKeyEx (HKEY_CURRENT_USER, Lprun,0, Key_write, &HKey); if(lret==error_success) {cout<<"Open OK"<<Endl; //Delete key LongTemp=regdeletevalue (HKey,"mgtest"); if(temp!=error_success) {cout<<"del fail"<<Endl; }Else{cout<<"del OK"<<Endl; } //Close KeyRegCloseKey (HKey); }Else{cout<<"Open Fail"<<Endl; }} getchar (); return 0;}
the path of the boot loader on the red background
C + + Registry operations