VC 注册表操作
//获取注册表值
HKEY hKEY;
LPCTSTR data_Set="SOFTWARE//INTERNET";
long ret0=::RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_Set, 0, KEY_ALL_ACCESS, &hKEY);
LPBYTE lpa = new BYTE[500];
DWORD dwAidSize=500;
DWORD type=REG_SZ;
long ret1=::RegQueryValueEx(hKEY,"123",NULL,&type,lpa,&dwAidSize);
long ret2=::RegCloseKey(hKEY);
//设置注册表值
HKEY hKEY;
LPCTSTR data_Set="SOFTWARE//MICROSOFT//INTERNET EXPLORER//TOOLBAR";
long ret0=::RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_Set, 0, KEY_ALL_ACCESS, &hKEY);
bool value=0;
long ret1=::RegSetValueEx(hKEY,"{123123}",0,REG_BINARY,(LPBYTE) &value,sizeof(value));
long ret2=::RegCloseKey(hKEY);
//删除注册表值
HKEY hKEY;
LPCTSTR data_Set="SOFTWARE//MICROSOFT//INTERNET EXPLORER//TOOLBAR";
long ret0=::RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_Set, 0, KEY_ALL_ACCESS, &hKEY);
long ret1=::RegDeleteValue(hKEY,"123123");
long ret2=::RegCloseKey(hKEY);
//创建注册表值
HKEY hKEY;
LPCTSTR data_Set="SOFTWARE//MICROSOFT//INTERNET EXPLORER//TOOLBAR";
// 打开注册表父目录,取得句柄
long ret0=::RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_Set, 0, KEY_ALL_ACCESS, &hKEY);
bool value=0;
long ret1=::RegSetValueEx(hKEY,"123123",0,REG_BINARY,(LPBYTE) &value,sizeof(value));
long ret2=::RegCloseKey(hKEY);
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/daocaoren0824/archive/2008/04/07/2257207.aspx