Using the System Registry

HomeOverviewHow Do I

Your Windows 95 application must not store any information in the WIN.INI and SYSTEM.INI files; instead, use the system registry to store any initialization information. MFC applications never store information in WIN.INI or SYSTEM.INI. Instead, they normally use a private .INI file to store information such as the MRU (most recently used) file list, the position of dockable toolbars, etc. Private .INI files are permissible for Windows 95 applications (though they are not recommended), as long as they are stored in the application directory and are deleted when the application is uninstalled.

You can make your MFC application compliant by using the CWinApp::SetRegistryKey function; this function makes your application use the registry instead of a private .INI file. Call this function from the InitInstance member function of your CWinApp-derived class, specifying the name of your software company (in string form) as the parameter; this creates a subkey in the registry (under HKEY_CURRENT_USER) with your software company’s name. After this function is called, all the information that your application would normally write to its .INI file is instead stored in the registry under that key.