现在的位置: 首页 > 综合 > 正文

VC更改对话框程序中的APPNAME

2013年10月09日 ⁄ 综合 ⁄ 共 744字 ⁄ 字号 评论关闭

看MSDN中CwinApp的CWinApp::m_pszAppName ,介绍如下

m_pszAppName is a public variable of type const char*.

Note   If you assign a value to m_pszAppName, it must be dynamically allocated on the heap. The CWinApp destructor calls free( ) with this pointer. You many want to use the _tcsdup( ) run-time library function to do the allocating. Also, free the memory associated
with the current pointer before assigning a new value. For example:

//First free the string allocated by MFC at CWinApp startup.
//The string is allocated before InitInstance is called.
free((void*)m_pszAppName);
//Change the name of the application file.
//The CWinApp destructor will free the memory.
m_pszAppName=_tcsdup(_T(“d:\\somedir\\myapp.exe”));

若要自行分配AppName,则先释放m_pszAppName,再通过动态内存分配更改appname

free((void*)m_pszAppName);

m_pszAppName=_tcsdup(_T(“d:\\somedir\\myapp.exe”));

即可

抱歉!评论已关闭.