When writing the MFC programming, the wizard will automatically create the key of this program in the registry to save some of the settings information of the program. But sometimes we don't want to save these configuration information to the registry, and there is an INI file (or other file) in the specified directory, we don't have to rewrite a Cinifile class, just need to cwinapp :: InitInstance () Several member variables for modifying CWINAPP can be, as follows:
// The following code is placed in InitInstance // First clears the memory space allocated by the registry key value variable. FREE ((void *) m_pszregistryKey); // Remove the INI variable Free ((void *) m_pszprofilename); // change INI file name. M_pszprofilename = _tcsdup ("d: //myprj/ininame.ini");
After completing the above settings, I can use the GetProfileString WriteProfileString functions.