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.

153 lines
3.8 KiB

  1. /* ----------------------------------------------------------------------
  2. Copyright (c) 1995-1996, Microsoft Corporation
  3. All rights reserved
  4. siMain.cpp - main Scrapi Interface
  5. Routines to interface with calling application.
  6. ---------------------------------------------------------------------- */
  7. #include "precomp.h"
  8. #include "clcnflnk.hpp"
  9. #include "version.h"
  10. // SDK stuff
  11. #include "NmApp.h" // To register CLSID_NetMeeting
  12. #include "NmSysInfo.h" // For CNmSysInfoObj
  13. #include "SDKInternal.h" // For NmManager, etc.
  14. #include "MarshalableTI.h" // For Marshalable Type Info
  15. // Global variable definitions (local to each instance)
  16. HINSTANCE g_hInst = NULL; // This dll's instance
  17. CComModule _Module;
  18. BEGIN_OBJECT_MAP(ObjectMap)
  19. OBJECT_ENTRY(CLSID_NetMeeting, CNetMeetingObj)
  20. OBJECT_ENTRY(CLSID_NmSysInfo, CNmSysInfoObj)
  21. OBJECT_ENTRY(CLSID_NmManager, CNmManagerObj)
  22. OBJECT_ENTRY(CLSID_MarshalableTI, CMarshalableTI)
  23. END_OBJECT_MAP()
  24. /* D L L M A I N */
  25. /*-------------------------------------------------------------------------
  26. %%Function: DllMain
  27. -------------------------------------------------------------------------*/
  28. BOOL WINAPI DllMain(HINSTANCE hDllInst, DWORD fdwReason, LPVOID lpv)
  29. {
  30. switch (fdwReason)
  31. {
  32. case DLL_PROCESS_ATTACH:
  33. {
  34. #ifdef DEBUG
  35. InitDebug();
  36. DBG_INIT_MEMORY_TRACKING(hDllInst);
  37. TRACE_OUT(("*** MSCONF.DLL: Attached process thread %X", GetCurrentThreadId()));
  38. #endif
  39. g_hInst = hDllInst;
  40. _Module.Init(ObjectMap, g_hInst);
  41. DisableThreadLibraryCalls(hDllInst);
  42. InitDataObjectModule();
  43. break;
  44. }
  45. case DLL_PROCESS_DETACH:
  46. _Module.Term();
  47. #ifdef DEBUG
  48. DBG_CHECK_MEMORY_TRACKING(hDllInst);
  49. TRACE_OUT(("*** MSCONF.DLL: Detached process thread %X", GetCurrentThreadId()));
  50. DeInitDebug();
  51. #endif
  52. break;
  53. case DLL_THREAD_ATTACH:
  54. case DLL_THREAD_DETACH:
  55. default:
  56. break;
  57. }
  58. return TRUE;
  59. }
  60. /////////////////////////////////////////////////////////////////////////////
  61. // Used to determine whether the DLL can be unloaded by OLE
  62. STDAPI DllCanUnloadNow(void)
  63. {
  64. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  65. }
  66. /////////////////////////////////////////////////////////////////////////////
  67. // Returns a class factory to create an object of the requested type
  68. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  69. {
  70. HRESULT hr = S_OK;
  71. if( InlineIsEqualGUID(rclsid, CLSID_NetMeeting) || InlineIsEqualGUID(rclsid, CLSID_NmManager) )
  72. {
  73. hr = CoGetClassObject(rclsid, CLSCTX_LOCAL_SERVER, NULL, riid, ppv);
  74. }
  75. else
  76. {
  77. hr = _Module.GetClassObject(rclsid, riid, ppv);
  78. }
  79. return hr;
  80. }
  81. /* D L L G E T V E R S I O N */
  82. /*-------------------------------------------------------------------------
  83. %%Function: DllGetVersion
  84. -------------------------------------------------------------------------*/
  85. STDAPI DllGetVersion(IN OUT DLLVERSIONINFO * pinfo)
  86. {
  87. HRESULT hr;
  88. if ((NULL == pinfo) ||
  89. IsBadWritePtr(pinfo, sizeof(*pinfo)) ||
  90. sizeof(*pinfo) != pinfo->cbSize)
  91. {
  92. hr = E_INVALIDARG;
  93. }
  94. else
  95. {
  96. pinfo->dwMajorVersion = (VER_PRODUCTVERSION_DW & 0xFF000000) >> 24;
  97. pinfo->dwMinorVersion = (VER_PRODUCTVERSION_DW & 0x00FF0000) >> 16;
  98. pinfo->dwBuildNumber = (VER_PRODUCTVERSION_DW & 0x0000FFFF);
  99. pinfo->dwPlatformID = DLLVER_PLATFORM_WINDOWS;
  100. hr = S_OK;
  101. }
  102. return hr;
  103. }
  104. /////////////////////////////////////////////////////////////////////////////
  105. // DllRegisterServer - Adds entries to the system registry
  106. STDAPI DllRegisterServer(void)
  107. {
  108. return _Module.RegisterServer();
  109. }
  110. /////////////////////////////////////////////////////////////////////////////
  111. // DllUnregisterServer - Removes entries from the system registry
  112. STDAPI DllUnregisterServer(void)
  113. {
  114. HRESULT hr = S_OK;
  115. hr = _Module.UnregisterServer();
  116. return hr;
  117. }