appterm.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10. #include "stdafx.h"
  11. #include <ddeml.h> // for MSGF_DDEMGR
  12. #ifdef AFX_TERM_SEG
  13. #pragma code_seg(AFX_TERM_SEG)
  14. #endif
  15. #ifdef _DEBUG
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. /////////////////////////////////////////////////////////////////////////////
  20. // other globals (internal library use)
  21. /////////////////////////////////////////////////////////////////////////////
  22. // Standard cleanup called by WinMain and AfxAbort
  23. void AFXAPI AfxWinTerm(void)
  24. {
  25. // unregister Window classes
  26. AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
  27. AfxLockGlobals(CRIT_REGCLASSLIST);
  28. LPTSTR lpsz = pModuleState->m_szUnregisterList;
  29. while (*lpsz != 0)
  30. {
  31. LPTSTR lpszEnd = _tcschr(lpsz, '\n');
  32. ASSERT(lpszEnd != NULL);
  33. *lpszEnd = 0;
  34. UnregisterClass(lpsz, AfxGetInstanceHandle());
  35. lpsz = lpszEnd + 1;
  36. }
  37. pModuleState->m_szUnregisterList[0] = 0;
  38. AfxUnlockGlobals(CRIT_REGCLASSLIST);
  39. // cleanup OLE if required
  40. CWinThread* pThread = AfxGetApp();
  41. if (pThread != NULL && pThread->m_lpfnOleTermOrFreeLib != NULL)
  42. (*pThread->m_lpfnOleTermOrFreeLib)(TRUE, FALSE);
  43. // cleanup thread local tooltip window
  44. _AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
  45. if (pThreadState->m_pToolTip != NULL)
  46. {
  47. if (pThreadState->m_pToolTip->DestroyToolTipCtrl())
  48. pThreadState->m_pToolTip = NULL;
  49. }
  50. if (!afxContextIsDLL)
  51. {
  52. // unhook windows hooks
  53. if (pThreadState->m_hHookOldMsgFilter != NULL)
  54. {
  55. ::UnhookWindowsHookEx(pThreadState->m_hHookOldMsgFilter);
  56. pThreadState->m_hHookOldMsgFilter = NULL;
  57. }
  58. if (pThreadState->m_hHookOldCbtFilter != NULL)
  59. {
  60. ::UnhookWindowsHookEx(pThreadState->m_hHookOldCbtFilter);
  61. pThreadState->m_hHookOldCbtFilter = NULL;
  62. }
  63. }
  64. }
  65. /////////////////////////////////////////////////////////////////////////////