I have the following line of code in my application:
CString strAppName = AfxGetAppName();
Sometimes it fills strAppName up with garbage characters, and I can't figure out why.
Anyone have any ideas?
TIA.
-
That is possible if you change
m_pszAppNamemanually.At the very beginning of application initialization,
AfxWinInitcallsCWinApp::SetCurrentHandles, which caches the current value of them_pszAppNamepointer as follows:
pModuleState->m_lpszCurrentAppName = m_pszAppName;That is, the module state struct holds a copy of the
m_pszAppNamepointer. If you changem_pszAppNameinInitInstanceas adviced in MSDN, you still have the old pointer value inpModuleState->m_lpszCurrentAppName. TheAfxGetAppName()function returnsAfxGetModuleState()->m_lpszCurrentAppName.You could add data breakpoint on m_lpszCurrentAppName and on
m_pszAppName. It is initialized in<...>\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc\appinit.cppfile. You'll see what is going on with that variable and who's trying to change it.Justin : My application does not change `m_pszAppName`. It changes some registry keys though, could that be the issue?Kirill V. Lyadvinsky : I don't think that changing registry keys could implicitly change `m_pszAppName`.
0 comments:
Post a Comment