in MFC look up CRegistry
or if you using standard API calls lookup
RegOpenKeyEx
RegQueryValueEx
RegSetValueEx
RegCloseKey
heres 2 functions i wrote in my own registry class, i dunno how good they are, but they work and are probably a useful start for you...
CRegistry::CRegistry()
{
char* pDefaultKey = "Software\\Unknown App\\Settings";
m_hRootKey = HKEY_LOCAL_MACHINE;
m_cSubKey = (char *)malloc((strlen(pDefaultKey) + 1) * sizeof(char));
strcpy(m_cSubKey, pDefaultKey);
m_hRegKey = NULL;
m_ulDataSize = 0;
}
bool CRegistry::OpenKey(char* KeyName, int* Value)
{
if (RegOpenKeyEx(m_hRootKey, m_cSubKey, 0, KEY_ALL_ACCESS, &m_hRegKey) == ERROR_SUCCESS)
{
// Successfully opened the key
m_ulDataSize = sizeof(DWORD);
if (RegQueryValueEx(m_hRegKey, KeyName, NULL, NULL, (LPBYTE)Value, (LPDWORD)&m_ulDataSize) == ERROR_SUCCESS)
{
RegCloseKey(m_hRegKey);
return true;
}
}
return false;
}
bool CRegistry::SaveKey(char* KeyName, char* Value)
{
unsigned long ulIsNew = 0;
HKEY hRegKey;
if (RegCreateKeyEx(m_hRootKey, m_cSubKey, NULL, NULL, NULL, KEY_WRITE, NULL, &hRegKey, &ulIsNew) == ERROR_SUCCESS)
{
if (RegSetValueEx(hRegKey, KeyName, 0, REG_SZ, (const BYTE *)Value, (DWORD)strlen(Value)) == ERROR_SUCCESS)
{
RegCloseKey(hRegKey);
return true;
}
}
return false;
}