Udostępnij za pośrednictwem


CWinApp::ExitInstance

This method is called by the framework to exit the application or DLL instance.

virtual int ExitInstance();

Return Value

For applications, the exit code. 0 indicates no errors, a non-zero value indicates an error. This value is used as the return value from WinMain.

For DLLs, the return value is ignored.

Remarks

You can override this method to perform cleanup when your application or DLL exits.

For applications, this method is called from CWinApp::Run. If you override CWinApp::Run, you must call ExitInstance before your override returns.

For DLLs, this method is called in response to the DLL_PROCESS_DETACH event. For more information, see DllMain.

This method calls CWinApp::SaveStdProfileSettings to save the application's profile settings to the registry.

Example

int CMyApp::ExitInstance()
{
  if (m_pMySampleMem)
     delete m_pMySampleMem;

   DoCleanup();

   return CWinApp::ExitInstance();
}

Requirements

Header: afxwin.h

See Also

Reference

CWinApp Class

Hierarchy Chart

CWinApp::Run

CWinApp::InitInstance

Other Resources

CWinApp Members

Change History

Date

History

Reason

July 2009

Added method description and return value for DLLs; Corrected section that describes profile saving behavior.

Customer feedback.