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.

117 lines
4.0 KiB

  1. /*======================================================================================//
  2. | Windows NT Process Control //
  3. | //
  4. |Copyright (c) 1999 Sequent Computer Systems, Incorporated. All rights reserved. //
  5. | //
  6. |File Name: ProcCon.cpp //
  7. | //
  8. |Description: //
  9. | //
  10. |Created: Paul Skoglund 07-1998 //
  11. | //
  12. |Rev History: //
  13. | 3-27-1999 renamed ProcMan to ProcCon //
  14. | //
  15. |=======================================================================================*/
  16. // Note: Proxy/Stub Information
  17. // To build a separate proxy/stub DLL,
  18. // run nmake -f ProcConps.mk in the project directory.
  19. #include "stdafx.h"
  20. #include "resource.h"
  21. #include "initguid.h"
  22. #include "ProcCon.h"
  23. #include "ProcCon_i.c"
  24. #include "ComponentData.h"
  25. #include "About.h"
  26. CComModule _Module;
  27. BEGIN_OBJECT_MAP(ObjectMap)
  28. OBJECT_ENTRY(CLSID_ComponentData, CComponentData)
  29. OBJECT_ENTRY(CLSID_About, CAbout)
  30. END_OBJECT_MAP()
  31. /////////////////////////////////////////////////////////////////////////////
  32. // DLL Entry Point
  33. extern "C"
  34. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  35. {
  36. if ( DLL_PROCESS_ATTACH == dwReason )
  37. {
  38. SetErrorMode(SEM_NOALIGNMENTFAULTEXCEPT);
  39. _Module.Init(ObjectMap, hInstance);
  40. DisableThreadLibraryCalls(hInstance);
  41. }
  42. else if ( DLL_PROCESS_DETACH == dwReason )
  43. _Module.Term();
  44. return TRUE;
  45. } // end DllMain()
  46. /////////////////////////////////////////////////////////////////////////////
  47. // Used to determine whether the DLL can be unloaded by OLE
  48. STDAPI DllCanUnloadNow(void)
  49. {
  50. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  51. }
  52. /////////////////////////////////////////////////////////////////////////////
  53. // Returns a class factory to create an object of the requested type
  54. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  55. {
  56. return _Module.GetClassObject(rclsid, riid, ppv);
  57. }
  58. /////////////////////////////////////////////////////////////////////////////
  59. // DllRegisterServer - Adds entries to the system registry
  60. STDAPI DllRegisterServer(void)
  61. {
  62. // registers object, typelib and all interfaces in typelib
  63. return _Module.RegisterServer(TRUE);
  64. }
  65. /////////////////////////////////////////////////////////////////////////////
  66. // DllUnregisterServer - Removes entries from the system registry
  67. STDAPI DllUnregisterServer(void)
  68. {
  69. // see atlbase.h source for this overloaded method that also unregisters typelib
  70. HRESULT hr = _Module.UnregisterServer(TRUE);
  71. /*
  72. if (FAILED(hr))
  73. return hr;
  74. change and use ATL CComModule::UnregisterServer(TRUE) that also unregisters the type library...
  75. #if _WIN32_WINNT >= 0x0400
  76. // possible interest...see knowledge base article
  77. // FIX: ATL Servers Do Not Unregister Their Type Library
  78. // Last reviewed: September 1, 1998
  79. // Article ID: Q179688
  80. HRESULT hr2 = UnRegisterTypeLib(LIBID_PROCCONLib, 1, 0, LOCALE_NEUTRAL, SYS_WIN32);
  81. // 04/16/1999 Paul Skoglund
  82. // if library has already been unregistered UnRegisterTypeLib() is
  83. // returning 0x8002801C -- TYPE_E_REGISTRYACCESS
  84. // seems like a bug...
  85. if (hr2 != TYPE_E_REGISTRYACCESS)
  86. return hr2;
  87. #endif
  88. */
  89. return hr;
  90. }