Leaked source code of windows server 2003
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
2.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992-2001.
  5. //
  6. // File: DLLMAIN . C P P
  7. //
  8. // Contents: Main entry points into the DLL
  9. //
  10. // Notes:
  11. //
  12. //----------------------------------------------------------------------------
  13. #include <windows.h>
  14. #include <shellapi.h>
  15. #include <shlobj.h>
  16. #include <atlbase.h>
  17. extern CComModule _Module; // required by atlcom.h
  18. #include <atlcom.h>
  19. #include <devguid.h>
  20. #include "notify.h"
  21. #include "notifyn_i.c"
  22. CComModule _Module;
  23. BEGIN_OBJECT_MAP(ObjectMap)
  24. OBJECT_ENTRY(CLSID_CMuxNotify, CMuxNotify)
  25. END_OBJECT_MAP()
  26. /////////////////////////////////////////////////////////////////////////////
  27. // DLL Entry Point
  28. extern "C"
  29. BOOL WINAPI DllMain (HINSTANCE hInstance,
  30. DWORD dwReason,
  31. LPVOID /*lpReserved*/)
  32. {
  33. TraceMsg( L"-->DllMain.\n");
  34. if (dwReason == DLL_PROCESS_ATTACH) {
  35. TraceMsg( L" Reason: Attach.\n");
  36. _Module.Init(ObjectMap, hInstance);
  37. DisableThreadLibraryCalls(hInstance);
  38. }
  39. else if (dwReason == DLL_PROCESS_DETACH) {
  40. TraceMsg( L" Reason: Detach.\n");
  41. _Module.Term();
  42. }
  43. TraceMsg( L"<--DllMain.\n");
  44. return TRUE;
  45. }
  46. /////////////////////////////////////////////////////////////////////////////
  47. // Used to determine whether the DLL can be unloaded by OLE
  48. STDAPI DllCanUnloadNow(void)
  49. {
  50. HRESULT hr;
  51. TraceMsg( L"-->DllCanUnloadNow.\n");
  52. hr = (_Module.GetLockCount() == 0) ? S_OK : S_FALSE;
  53. TraceMsg( L"-->DllCanUnloadNow(HRESULT = %x).\n",
  54. hr );
  55. return hr;
  56. }
  57. /////////////////////////////////////////////////////////////////////////////
  58. // Returns a class factory to create an object of the requested type
  59. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  60. {
  61. TraceMsg( L"-->DllGetClassObject.\n");
  62. return _Module.GetClassObject(rclsid, riid, ppv);
  63. }
  64. /////////////////////////////////////////////////////////////////////////////
  65. // DllRegisterServer - Adds entries to the system registry
  66. STDAPI DllRegisterServer(void)
  67. {
  68. // Registers object, typelib and all interfaces in typelib
  69. TraceMsg( L"-->DllRegisterServer.\n");
  70. return _Module.RegisterServer(TRUE);
  71. }
  72. /////////////////////////////////////////////////////////////////////////////
  73. // DllUnregisterServer - Removes entries from the system registry
  74. STDAPI DllUnregisterServer(void)
  75. {
  76. TraceMsg( L"-->DllUnregisterServer.\n");
  77. _Module.UnregisterServer();
  78. return S_OK;
  79. }