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.

120 lines
3.2 KiB

  1. // atl.cpp : Implementation of DLL Exports.
  2. // You will need the NT SUR Beta 2 SDK or VC 4.2 or higher in order to build
  3. // this project. This is because you will need MIDL 3.00.15 or higher and new
  4. // headers and libs. If you have VC 4.2 installed, then everything should
  5. // already be configured correctly.
  6. // Note: Proxy/Stub Information
  7. // To build a separate proxy/stub DLL,
  8. // run nmake -f atlps.mak in the project directory.
  9. #include "stdafx.h"
  10. #include "resource.h"
  11. #include "RegObj.h"
  12. #define _ATLBASE_IMPL
  13. #include <atlbase.h>
  14. #define _ATLCOM_IMPL
  15. #include <atlcom.h>
  16. #define _ATLWIN_IMPL
  17. #include <atlwin.h>
  18. #define _ATLCTL_IMPL
  19. #include <atlctl.h>
  20. #define _ATLCONV_IMPL
  21. #include <atlconv.h>
  22. #define _ATLHOST_IMPL
  23. #include <atlhost.h>
  24. CComModule _Module;
  25. BEGIN_OBJECT_MAP(ObjectMap)
  26. OBJECT_ENTRY(CLSID_Registrar, CDLLRegObject)
  27. OBJECT_ENTRY_NON_CREATEABLE(CAxHostWindow)
  28. END_OBJECT_MAP()
  29. /////////////////////////////////////////////////////////////////////////////
  30. // DLL Entry Point
  31. extern "C"
  32. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  33. {
  34. if (dwReason == DLL_PROCESS_ATTACH)
  35. {
  36. OSVERSIONINFOA info;
  37. info.dwOSVersionInfoSize = sizeof(info);
  38. if (GetVersionExA(&info))
  39. {
  40. #ifdef _UNICODE
  41. if (info.dwPlatformId != VER_PLATFORM_WIN32_NT)
  42. {
  43. MessageBoxA(NULL, "Can not run Unicode version of ATL.DLL on Windows 95.\nPlease install the correct version.", "ATL", MB_ICONSTOP|MB_OK);
  44. return FALSE;
  45. }
  46. #else
  47. if (info.dwPlatformId == VER_PLATFORM_WIN32_NT)
  48. {
  49. OutputDebugString(_T("Running Ansi version of ATL.DLL on Windows NT : Slight Performace loss.\nPlease install the UNICODE version on NT.\n"));
  50. }
  51. #endif
  52. }
  53. #ifdef _DEBUG
  54. _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF);
  55. int n = 0;
  56. _CrtSetBreakAlloc(n);
  57. #endif
  58. _Module.Init(ObjectMap, hInstance, &LIBID_ATLLib);
  59. #ifdef _ATL_DEBUG_INTERFACES
  60. int ni = 0;
  61. _Module.m_nIndexBreakAt = ni;
  62. #endif // _ATL_DEBUG_INTERFACES
  63. DisableThreadLibraryCalls(hInstance);
  64. }
  65. else if (dwReason == DLL_PROCESS_DETACH)
  66. {
  67. #ifdef _DEBUG
  68. ::OutputDebugString(_T("ATL.DLL exiting.\n"));
  69. #endif
  70. _Module.Term();
  71. AtlAxWinTerm();
  72. #ifdef _DEBUG
  73. if (_CrtDumpMemoryLeaks())
  74. ::MessageBeep(MB_ICONEXCLAMATION);
  75. #endif
  76. }
  77. return TRUE; // ok
  78. }
  79. /////////////////////////////////////////////////////////////////////////////
  80. // Used to determine whether the DLL can be unloaded by OLE
  81. STDAPI DllCanUnloadNow(void)
  82. {
  83. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  84. }
  85. /////////////////////////////////////////////////////////////////////////////
  86. // Returns a class factory to create an object of the requested type
  87. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  88. {
  89. return _Module.GetClassObject(rclsid, riid, ppv);
  90. }
  91. /////////////////////////////////////////////////////////////////////////////
  92. // DllRegisterServer - Adds entries to the system registry
  93. STDAPI DllRegisterServer(void)
  94. {
  95. // registers object, typelib and all interfaces in typelib
  96. return _Module.RegisterServer(TRUE);
  97. }
  98. /////////////////////////////////////////////////////////////////////////////
  99. // DllUnregisterServer - Removes entries from the system registry
  100. STDAPI DllUnregisterServer(void)
  101. {
  102. //No need to unregister typelib since ATL is a system component.
  103. return S_OK;
  104. }