In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Today, I will talk to you about what is the code for reading and writing binary data in the registry, which may not be well understood by many people. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
1. RegOpenKeyEx function:
Original form:
LONGRegOpenKeyEx (the subkey or path that HKEYhKey,// needs to open in order to open the primary key name LPCTSTRlpSubKey,// is reserved by DWORDulOptions,//. For 0 REGSAMsamDesired,// operation permission flag, PHKEYphkResult// points to the handle to your key (returned by pointer))
Return value: non-0 is returned if not successful, ERROR_SUCCESS is returned successfully. Explanation: this function is responsible for opening the specified key or subkey, if it does not exist, it does not create.
Check out Microsoft's official documentation: http://msdn.microsoft.com/zh-cn/aa912084
2. RegSetValueEx function:
Original form:
LONGRegSetValueEx (the name of the value to be queried by the handle of the key opened by HKEYhKey,//, such as\ "\" keep the length of the DWORDcbData// variable that DWORDdwType,// writes to the type CONSTBYTE*lpData,// variable data of the type of key value for the default value DWORDReserved,// under the query key)
Return value: non-0 is returned if not successful, ERROR_SUCCESS explanation is returned successfully: set the value of a specific name under a subkey.
Check out Microsoft's official documentation: http://msdn.microsoft.com/zh-cn/aa916717#
3. RegQueryValueEx function:
Original form:
LONGRegQueryValueEx (the name of the value to be queried by the handle of the key opened by HKEYhKey,//, such as\ "\" is reserved for the default value LPDWORDlpReserved,// under the query key, and the address of LPBYTElpData,// data stored in the type of 0 LPDWORDlpType,// query is LPDWORDlpcbData// data length + 1)
Return value: non-0 is returned if not successful, ERROR_SUCCESS explanation is returned successfully: read the value of a specific name under a subkey.
Check out Microsoft's official documentation: http://msdn.microsoft.com/zh-cn/aa914692
Write binary data code example:
# include # include int main (void) {HKEY hKey;HKEY rootKey = HKEY_CURRENT_USER;TCHAR * subKey = "Software\\ Microsoft\\ Windows\\ CurrentVersion\ Explorer"\\ MenuOrder\\ Start Menu2\\ Programs\\ test"; TCHAR * keyValue = "c:\ test.exe"; long openReg;long setRegValue;DWORD dwType = REG_BINARY;BYTE value [256] = "c:\\ test.exe"; openReg = RegOpenKeyEx (rootKey, subKey, 0, KEY_WRITE, & hKey) If (openReg = = ERROR_SUCCESS) {setRegValue = RegSetValueEx (hKey, _ T ("order"), 0, dwType, value, 256); if (setRegValue = = ERROR_SUCCESS) {MessageBox (NULL, _ T ("Write Sucess"), _ T ("call"), MB_OK);} else {MessageBox (NULL, _ T ("Write Fail"), _ T ("call"), MB_OK);} RegCloseKey (hKey);} return 0;}
Sample code to read binary data:
# include # include int main (void) {HKEY hKey;HKEY rootKey = HKEY_CURRENT_USER;TCHAR * subKey = "Software\\ Microsoft\\ Windows\\ CurrentVersion\\ Explorer"\\ MenuOrder\\ Start Menu2\\ Programs\\ test"; long openRegResult;long readRegResult;DWORD dwType = REG_BINARY;REGSAM mode = KEY_READ;BYTE value [256] = {0}; DWORD length = 256 openRegResult = RegOpenKeyEx (rootKey, subKey, 0, mode, & hKey) If (ERROR_SUCCESS = = openRegResult) {readRegResult = RegQueryValueEx (hKey, _ T ("order"), 0, & dwType, value, & length); if (ERROR_SUCCESS = = readRegResult) {MessageBox (NULL, _ T (value), _ T ("call"), MB_OK);} else {MessageBox (NULL, _ T ("ERROR"), _ T ("call"), MB_OK);}} RegCloseKey (hKey); return 0;}
Note: read and write other types of registry key values similar to the above, not explained separately.
After reading the above, do you have any further understanding of what is the code for reading and writing binary data in the registry? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.