AfxGetApp CWinApp* AfxGetApp( ); Return ValueA pointer to the single CWinApp object for the application.ResThe pointer returned by this function can be used to access application information such as the main message-dispatch code or the topmost window. theApp是一个全局变量,用来指向程序本身,而函数AfxGetApp( )的作用也是得到指向应用程序的指针,所以他们两个实际上是相同的。
CWinApp* AfxGetApp( ); Return ValueA pointer to the single CWinApp object for the application.ResThe pointer returned by this function can be used to access application information such as the main message-dispatch code or the topmost window.
theApp是一个全局变量,用来指向程序本身,而函数AfxGetApp( )的作用也是得到指向应用程序的指针,所以他们两个实际上是相同的。
其中AfxGetApp()的定义为:
CWinApp* AfxGetApp()
{
return theApp.m_pCurrentWinApp;
}
m_pCurrentWinApp = this;
注意这个this指针,它是指向全局对象theApp的
所以pApp当然是指向全局对象theApp的至于你说“它应该指向的是这个全局变量中间的一个数据段吧”不知是啥意思?