Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.4 KiB

  1. /*--------------------------------------------------------------------------*
  2. *
  3. * Microsoft Windows
  4. * Copyright (C) Microsoft Corporation, 1992 - 00
  5. *
  6. * File: mmcbase.cpp
  7. *
  8. * Contents: Main entry point for mmcbase.dll
  9. *
  10. * History: 7-Jan-2000 jeffro Created
  11. *
  12. *--------------------------------------------------------------------------*/
  13. #include "stdafx.h"
  14. #include "atlimpl.cpp"
  15. #include "atlwin.cpp"
  16. static SC ScInitAsMFCExtensionModule (HINSTANCE hInstance);
  17. // the one and only instance.
  18. CComModule _Module;
  19. /*+-------------------------------------------------------------------------*
  20. *
  21. * DllMain
  22. *
  23. * PURPOSE: The main DLL entry point
  24. *
  25. * PARAMETERS:
  26. * HANDLE hModule :
  27. * DWORD dwReason :
  28. * LPVOID lpReserved :
  29. *
  30. * RETURNS:
  31. * BOOL APIENTRY
  32. *
  33. *+-------------------------------------------------------------------------*/
  34. BOOL APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  35. {
  36. if (dwReason == DLL_PROCESS_ATTACH)
  37. {
  38. // set the module instance for error codes.
  39. SC::SetHinst(hInstance);
  40. /*
  41. * attach this module to MFC's resource search path
  42. */
  43. if (ScInitAsMFCExtensionModule(hInstance).IsError())
  44. return (FALSE); // bail out
  45. _Module.Init(NULL, hInstance);
  46. DisableThreadLibraryCalls(hInstance);
  47. }
  48. else if (dwReason == DLL_PROCESS_DETACH)
  49. {
  50. _Module.Term();
  51. }
  52. return TRUE; // ok
  53. }
  54. /*+-------------------------------------------------------------------------*
  55. * ScInitAsMFCExtensionModule
  56. *
  57. * Initializes this module as an MFC extension. This is required so MFC
  58. * code will automatically search this module for resources (in particular,
  59. * strings).
  60. *--------------------------------------------------------------------------*/
  61. static SC ScInitAsMFCExtensionModule (HINSTANCE hInstance)
  62. {
  63. DECLARE_SC (sc, _T("ScInitAsMFCExtensionModule"));
  64. /*
  65. * extensionDLL must be static so it lives as long as dynLinkLib below
  66. */
  67. static AFX_EXTENSION_MODULE extensionDLL = { 0 };
  68. if (!AfxInitExtensionModule (extensionDLL, hInstance))
  69. return (sc = E_FAIL);
  70. /*
  71. * Declare a static CDynLinkLibrary for MMC. Its constructor will
  72. * add it to the list of modules MFC will search for resources. It
  73. * must be static so it will live as long as MMC.
  74. */
  75. new CDynLinkLibrary (extensionDLL);
  76. return (sc);
  77. }