I've been trying to write into the registry some data not related to the application in case. As it happens CWinApp functions are not intended for such usage -- they are intended to write the registration data of the running application. In that case the correct usage is as follows: 1. Place call to the SetRegistryKey function in the "InitInstance". For example,
BOOL DerivedApp::InitInstance()
{
// Standard initialization
LPCTSTR lpszRegistryKey = "SomeSection" ;
SetRegistryKey(lpszRegistryKey) ;
. . .
}
2. Place call to the other necessary functions in the proper place of your application. For example,
void SomeClass::OnStart()
{
. . .
LPCTSTR lpszSection = "SomeSection" ;
LPCTSTR lpszStringItem = "SomeString" ;
LPCTSTR lpszValue = "SomeStringValue" ;
if (!AfxGetApp()->;WriteProfileString(lpszSection, lpszStringItem, lpszValue))
AfxMessageBox("Registry settings weren't modified.") ;
. . .
}
I've checked it -- it works. But not in the case if you have to write into the Registry some data not related to your application. Regards to all of you, chaps!