1)读写注册表主要的几个API:
i) RegOpenKeyEx() 打开
ii)RegSetValueEx() 写
iii)RegQueryValueEx() 查询
2)for example:
写REG_DWORD型的注册表值,写成我们想要的dwValue: 把regSetValueEx函数的最后两个参数传入(const BYTE*)dwValue, sizeof(dwValue)
BOOL SetRegValue() { BOOL bRet = FALSE; HKEY hKey; LPCTSTR date_set = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"); LONG lResult = ::RegOpenKeyEx(HKEY_CURRENT_USER, date_set, 0, KEY_WRITE, &hKey); if(lResult == ERROR_SUCCESS) { DWORD dwValue = 0XBD; LONG lRet = ::RegSetValueEx(hKey, _T("NoDriveTypeAutoRun"), 0, REG_DWORD, (const BYTE*)&dwValue, sizeof(dwValue)); RegCloseKey(hKey); bRet = (lRet == ERROR_SUCCESS)? TRUE : FALSE; } return bRet; }
3)这三个函数的参数详情请查看msdn、