When you create a new MFC project there will be a call to
SetRegistryKey()
placed at
InitInstance
. Change the string to your company name. This will use the registry instead of INI files for profile settings. The used registry path will be
HKCU\Software\<company_name>\<application_name>
.
Then just use the
CWinApp
Get and Set profile functions. To call them from other classes than your
CWinApp
derived class use
AfxGetApp()
:
AfxGetApp()->WriteProfileInt(_T("Settings"), _T("AddStudent"), m_chkAddStudentVal);
m_chkAddStudentVal = AfxGetApp()->GetProfileInt(_T("Settings"), _T("AddStudent"), 0) ? 1 : 0;
Choose appropriate section and key names. I have used "Settings" as section name because it is common to store recent settings at program termination.