写入注册表
1 void CHkeyTestDlg::OnBnClickedButton2() 2 { 3 // TODO: 在此添加控件通知处理程序代码 4 HKEY hKey; 5 HKEY hTempKey; 6 DWORD dwValue=6; 7 DWORD dwSize=sizeof(DWORD); 8 DWORD dwType=REG_DWORD; 9 10 LPCTSTR data_Set=_T("Software"); 11 if(ERROR_SUCCESS==::RegOpenKeyEx(HKEY_CURRENT_USER,data_Set,0,KEY_SET_VALUE,&hKey)) 12 { 13 if(ERROR_SUCCESS==::RegCreateKey(hKey,_T("test111"),&hTempKey)) 14 { 15 if (ERROR_SUCCESS!=::RegSetValueEx(hTempKey,_T("Name"),0,REG_DWORD,(CONST BYTE*)&dwValue,sizeof(DWORD))) 16 { 17 AfxMessageBox(_T("错误")); 18 ::RegCloseKey(hKey); 19 return; 20 } 21 } 22 } 23 ::RegCloseKey(hKey); 24 }
参考: https://blog.csdn.net/yu12345678900/article/details/45442947
注册表百度百科 https://baike.baidu.com/item/%E6%B3%A8%E5%86%8C%E8%A1%A8/101856?fr=aladdin