gpt4 book ai didi

c++ - AfxGetAppName() 返回垃圾字符

转载 作者:搜寻专家 更新时间:2023-10-31 00:23:50 25 4
gpt4 key购买 nike

我的应用程序中有以下代码行:

CString strAppName = AfxGetAppName();

有时它会用垃圾字符填充 strAppName,我不明白为什么。

有人有什么想法吗?

TIA。

最佳答案

如果你改变 m_pszAppName 是可能的手动。

At the very beginning of application initialization, AfxWinInit calls CWinApp::SetCurrentHandles, which caches the current value of the m_pszAppName pointer as follows:
pModuleState->m_lpszCurrentAppName = m_pszAppName;

That is, the module state struct holds a copy of the m_pszAppName pointer. If you change m_pszAppName in InitInstance as adviced in MSDN, you still have the old pointer value in pModuleState->m_lpszCurrentAppName. The AfxGetAppName() function returns AfxGetModuleState()->m_lpszCurrentAppName.

您可以添加 data breakpoint在 m_lpszCurrentAppName 和 m_pszAppName 上.它在 <...>\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc\appinit.cpp 中初始化文件。您将看到该变量发生了什么,以及谁在尝试更改它。

关于c++ - AfxGetAppName() 返回垃圾字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1268005/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com