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.

151 lines
3.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997 - 2000
  5. //
  6. // File: D L L M A I N . C P P
  7. //
  8. // Contents: DLL entry points for hnetcfg.dll
  9. //
  10. // Notes:
  11. //
  12. // Author: jonburs 22 May 2000
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "dlldatax.h"
  18. #ifdef _MERGE_PROXYSTUB
  19. extern "C" HINSTANCE hProxyDll;
  20. #endif
  21. // extern
  22. extern void SetSAUIhInstance (HINSTANCE hInstance); // in saui.cpp
  23. // Global
  24. CComModule _Module;
  25. BEGIN_OBJECT_MAP(ObjectMap)
  26. OBJECT_ENTRY(CLSID_UPnPNAT, CUPnPNAT)
  27. OBJECT_ENTRY(CLSID_HNetCfgMgr, CHNetCfgMgr)
  28. OBJECT_ENTRY(CLSID_NetSharingManager, CNetSharingManager)
  29. OBJECT_ENTRY(CLSID_AlgSetup, CAlgSetup)
  30. END_OBJECT_MAP()
  31. HRESULT
  32. CompileMof(
  33. );
  34. //+---------------------------------------------------------------------------
  35. // DLL Entry Point
  36. //
  37. EXTERN_C
  38. BOOL
  39. WINAPI
  40. DllMain(
  41. HINSTANCE hInstance,
  42. DWORD dwReason,
  43. LPVOID pvReserved
  44. )
  45. {
  46. if ( !PrxDllMain(hInstance, dwReason, pvReserved) )
  47. {
  48. return FALSE;
  49. }
  50. if (dwReason == DLL_PROCESS_ATTACH)
  51. {
  52. ::DisableThreadLibraryCalls(hInstance);
  53. _Module.Init(ObjectMap, hInstance, &LIBID_NETCONLib);
  54. InitializeOemApi( hInstance );
  55. SetSAUIhInstance (hInstance);
  56. EnableOEMExceptionHandling();
  57. EnableNATExceptionHandling();
  58. }
  59. else if (dwReason == DLL_PROCESS_DETACH)
  60. {
  61. _Module.Term();
  62. ReleaseOemApi();
  63. DisableOEMExceptionHandling();
  64. DisableNATExceptionHandling();
  65. } else if (dwReason == DLL_THREAD_ATTACH) {
  66. EnableOEMExceptionHandling();
  67. EnableNATExceptionHandling();
  68. } else if (dwReason == DLL_THREAD_DETACH) {
  69. DisableOEMExceptionHandling();
  70. DisableNATExceptionHandling();
  71. }
  72. return TRUE;
  73. }
  74. /////////////////////////////////////////////////////////////////////////////
  75. // Used to determine whether the DLL can be unloaded by OLE
  76. STDAPI DllCanUnloadNow(VOID)
  77. {
  78. if ( PrxDllCanUnloadNow() != S_OK )
  79. {
  80. return S_FALSE;
  81. }
  82. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  83. }
  84. /////////////////////////////////////////////////////////////////////////////
  85. // Returns a class factory to create an object of the requested type
  86. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  87. {
  88. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  89. {
  90. return S_OK;
  91. }
  92. return _Module.GetClassObject(rclsid, riid, ppv);
  93. }
  94. //+---------------------------------------------------------------------------
  95. // DllRegisterServer - Adds entries to the system registry
  96. //
  97. STDAPI
  98. DllRegisterServer()
  99. {
  100. HRESULT hr = PrxDllRegisterServer();
  101. if ( FAILED(hr) )
  102. return hr;
  103. hr = _Module.RegisterServer(TRUE);
  104. if (SUCCEEDED(hr)) // register second typelib
  105. hr = _Module.RegisterTypeLib (_T("\\2"));
  106. return hr;
  107. }
  108. //+---------------------------------------------------------------------------
  109. // DllUnregisterServer - Removes entries from the system registry
  110. //
  111. STDAPI
  112. DllUnregisterServer()
  113. {
  114. PrxDllUnregisterServer();
  115. _Module.UnregisterServer(TRUE);
  116. _Module.UnRegisterTypeLib (_T("\\2"));
  117. return S_OK;
  118. }