Category Archives: Windows

Preventing Renamed App From Creating New Registry Entry

In Visual Studio 2008, I was using MFC’s registry calls to save my program preferences.  The problem was new builds weren’t using the prior build’s settings. I was adding the build number to the .exe filename and this caused a new key to be created in the registry based on the .exe name and a new set of settings saved therein.  Inspecting CWinApp‘s m_pszAppName and m_pszExeName I saw both were PuffinApp914.  It turns out m_pszAppName is set to the string resource ID AFX_IDS_APP_TITLE if it’s there.  If AFX_IDS_APP_TITLE doesn’t exist then m_pszAppName is set to the .exe filename.  After adding AFX_IDS_APP_TITLE to the project’s string resources m_pszAppName became Puffin and m_pszExeName stayed with PuffinApp914.  The registry calls use m_pszAppName for the key so my problem was solved.