Hi,
Does anyone know of a way to change the root registry key from HKEY_CURRENT_USER to HKEY_LOCAL_MACHINE.
I do the following code:
SetRegistryKey(_T("CTI");
m_pszProfileName = _tcsdup(_T("TIP Medical");
LoadStdProfileSettings();
CString strTemp;
strTemp = GetProfileString(_T("Paths", _T("TIPDir");
strTemp will always get the key value for TIPDir from
HKEY_CURRENT_USER\Software\CTI\TIP Medical\Paths\TIPDir.
GetProfileString() calls GetSectionKey() which calls GetAppRegistryKey().
GetAppRegistryKey()calls RegOpenKeyEx() always with the HKEY_CURRENT_USER root key.
HKEY CWinApp::GetAppRegistryKey()
{
ASSERT(m_pszRegistryKey != NULL);
ASSERT(m_pszProfileName != NULL);
HKEY hAppKey = NULL;
HKEY hSoftKey = NULL;
HKEY hCompanyKey = NULL;
if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("software", 0, KEY_WRITE|KEY_READ,
&hSoftKey) == ERROR_SUCCESS)
{
DWORD dw;
if (RegCreateKeyEx(hSoftKey, m_pszRegistryKey, 0, REG_NONE,
REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL,
&hCompanyKey, &dw) == ERROR_SUCCESS)
{
RegCreateKeyEx(hCompanyKey, m_pszProfileName, 0, REG_NONE,
REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL,
&hAppKey, &dw);
}
}
if (hSoftKey != NULL)
RegCloseKey(hSoftKey);
if (hCompanyKey != NULL)
RegCloseKey(hCompanyKey);
return hAppKey;
}
Any help will be appreciated.
Thanks
Gary
Does anyone know of a way to change the root registry key from HKEY_CURRENT_USER to HKEY_LOCAL_MACHINE.
I do the following code:
SetRegistryKey(_T("CTI");
m_pszProfileName = _tcsdup(_T("TIP Medical");
LoadStdProfileSettings();
CString strTemp;
strTemp = GetProfileString(_T("Paths", _T("TIPDir");
strTemp will always get the key value for TIPDir from
HKEY_CURRENT_USER\Software\CTI\TIP Medical\Paths\TIPDir.
GetProfileString() calls GetSectionKey() which calls GetAppRegistryKey().
GetAppRegistryKey()calls RegOpenKeyEx() always with the HKEY_CURRENT_USER root key.
HKEY CWinApp::GetAppRegistryKey()
{
ASSERT(m_pszRegistryKey != NULL);
ASSERT(m_pszProfileName != NULL);
HKEY hAppKey = NULL;
HKEY hSoftKey = NULL;
HKEY hCompanyKey = NULL;
if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("software", 0, KEY_WRITE|KEY_READ,
&hSoftKey) == ERROR_SUCCESS)
{
DWORD dw;
if (RegCreateKeyEx(hSoftKey, m_pszRegistryKey, 0, REG_NONE,
REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL,
&hCompanyKey, &dw) == ERROR_SUCCESS)
{
RegCreateKeyEx(hCompanyKey, m_pszProfileName, 0, REG_NONE,
REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL,
&hAppKey, &dw);
}
}
if (hSoftKey != NULL)
RegCloseKey(hSoftKey);
if (hCompanyKey != NULL)
RegCloseKey(hCompanyKey);
return hAppKey;
}
Any help will be appreciated.
Thanks
Gary