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.

161 lines
5.1 KiB

  1. // GuideStore.cpp : Implementation of DLL Exports.
  2. // Note: Proxy/Stub Information
  3. // To merge the proxy/stub code into the object DLL, add the file
  4. // dlldatax.c to the project. Make sure precompiled headers
  5. // are turned off for this file, and add _MERGE_PROXYSTUB to the
  6. // defines for the project.
  7. //
  8. // If you are not running WinNT4.0 or Win95 with DCOM, then you
  9. // need to remove the following define from dlldatax.c
  10. // #define _WIN32_WINNT 0x0400
  11. //
  12. // Further, if you are running MIDL without /Oicf switch, you also
  13. // need to remove the following define from dlldatax.c.
  14. // #define USE_STUBLESS_PROXY
  15. //
  16. // Modify the custom build rule for GuideStore.idl by adding the following
  17. // files to the Outputs.
  18. // GuideStore_p.c
  19. // dlldata.c
  20. // To build a separate proxy/stub DLL,
  21. // run nmake -f GuideStoreps.mk in the project directory.
  22. #include "stdafx.h"
  23. #include "resource.h"
  24. #include <initguid.h>
  25. #include "dlldatax.h"
  26. #include <mstvgs_i.c>
  27. #include "Property.h"
  28. #include "GuideStore2.h"
  29. #include "Service.h"
  30. #include "Program.h"
  31. #include "ScheduleEntry.h"
  32. #include "Channel.h"
  33. #include "object.h"
  34. #include "GuideDataProvider.h"
  35. #ifdef _MERGE_PROXYSTUB
  36. extern "C" HINSTANCE hProxyDll;
  37. #endif
  38. CComModule _Module;
  39. BEGIN_OBJECT_MAP(ObjectMap)
  40. #if 0
  41. OBJECT_ENTRY(CLSID_MetaPropertySet, CMetaPropertySet)
  42. OBJECT_ENTRY(CLSID_MetaPropertySets, CMetaPropertySets)
  43. OBJECT_ENTRY(CLSID_MetaPropertyType, CMetaPropertyType)
  44. OBJECT_ENTRY(CLSID_MetaPropertyTypes, CMetaPropertyTypes)
  45. OBJECT_ENTRY(CLSID_MetaProperty, CMetaProperty)
  46. OBJECT_ENTRY(CLSID_MetaProperties, CMetaProperties)
  47. OBJECT_ENTRY(CLSID_MetaPropertyCondition, CMetaPropertyCondition)
  48. OBJECT_ENTRY(CLSID_GuideStore, CGuideStore)
  49. OBJECT_ENTRY(CLSID_Service, CService)
  50. OBJECT_ENTRY(CLSID_Services, CServices)
  51. OBJECT_ENTRY(CLSID_Program, CProgram)
  52. OBJECT_ENTRY(CLSID_Programs, CPrograms)
  53. OBJECT_ENTRY(CLSID_ScheduleEntry, CScheduleEntry)
  54. OBJECT_ENTRY(CLSID_ScheduleEntries, CScheduleEntries)
  55. OBJECT_ENTRY(CLSID_Channel, CChannel)
  56. OBJECT_ENTRY(CLSID_Channels, CChannels)
  57. OBJECT_ENTRY(CLSID_ChannelLineup, CChannelLineup)
  58. OBJECT_ENTRY(CLSID_ChannelLineups, CChannelLineups)
  59. OBJECT_ENTRY(CLSID_Object, CObject)
  60. OBJECT_ENTRY(CLSID_ObjectType, CObjectType)
  61. OBJECT_ENTRY(CLSID_Objects, CObjects)
  62. OBJECT_ENTRY(CLSID_ObjectTypes, CObjectTypes)
  63. OBJECT_ENTRY(CLSID_TestTuneRequest, CTestTuneRequest)
  64. OBJECT_ENTRY(CLSID_GuideDataProvider, CGuideDataProvider)
  65. OBJECT_ENTRY(CLSID_GuideDataProviders, CGuideDataProviders)
  66. #else
  67. OBJECT_ENTRY(CLSID_GuideStore, CGuideStore)
  68. OBJECT_ENTRY(CLSID_Objects, CObjects)
  69. OBJECT_ENTRY(CLSID_Service, CService)
  70. OBJECT_ENTRY(CLSID_Services, CServices)
  71. OBJECT_ENTRY(CLSID_Program, CProgram)
  72. OBJECT_ENTRY(CLSID_Programs, CPrograms)
  73. OBJECT_ENTRY(CLSID_ScheduleEntry, CScheduleEntry)
  74. OBJECT_ENTRY(CLSID_ScheduleEntries, CScheduleEntries)
  75. OBJECT_ENTRY(CLSID_Channel, CChannel)
  76. OBJECT_ENTRY(CLSID_Channels, CChannels)
  77. OBJECT_ENTRY(CLSID_ChannelLineup, CChannelLineup)
  78. OBJECT_ENTRY(CLSID_ChannelLineups, CChannelLineups)
  79. OBJECT_ENTRY(CLSID_GuideDataProvider, CGuideDataProvider)
  80. OBJECT_ENTRY(CLSID_GuideDataProviders, CGuideDataProviders)
  81. #endif
  82. END_OBJECT_MAP()
  83. /////////////////////////////////////////////////////////////////////////////
  84. // DLL Entry Point
  85. extern "C"
  86. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  87. {
  88. lpReserved;
  89. #ifdef _MERGE_PROXYSTUB
  90. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  91. return FALSE;
  92. #endif
  93. if (dwReason == DLL_PROCESS_ATTACH)
  94. {
  95. _Module.Init(ObjectMap, hInstance, &LIBID_GUIDESTORELib);
  96. DisableThreadLibraryCalls(hInstance);
  97. }
  98. else if (dwReason == DLL_PROCESS_DETACH)
  99. _Module.Term();
  100. return TRUE; // ok
  101. }
  102. /////////////////////////////////////////////////////////////////////////////
  103. // Used to determine whether the DLL can be unloaded by OLE
  104. STDAPI DllCanUnloadNow(void)
  105. {
  106. #ifdef _MERGE_PROXYSTUB
  107. if (PrxDllCanUnloadNow() != S_OK)
  108. return S_FALSE;
  109. #endif
  110. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  111. }
  112. /////////////////////////////////////////////////////////////////////////////
  113. // Returns a class factory to create an object of the requested type
  114. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  115. {
  116. #ifdef _MERGE_PROXYSTUB
  117. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  118. return S_OK;
  119. #endif
  120. return _Module.GetClassObject(rclsid, riid, ppv);
  121. }
  122. /////////////////////////////////////////////////////////////////////////////
  123. // DllRegisterServer - Adds entries to the system registry
  124. STDAPI DllRegisterServer(void)
  125. {
  126. #ifdef _MERGE_PROXYSTUB
  127. HRESULT hRes = PrxDllRegisterServer();
  128. if (FAILED(hRes))
  129. return hRes;
  130. #endif
  131. // registers object, typelib and all interfaces in typelib
  132. return _Module.RegisterServer(TRUE);
  133. }
  134. /////////////////////////////////////////////////////////////////////////////
  135. // DllUnregisterServer - Removes entries from the system registry
  136. STDAPI DllUnregisterServer(void)
  137. {
  138. #ifdef _MERGE_PROXYSTUB
  139. PrxDllUnregisterServer();
  140. #endif
  141. return _Module.UnregisterServer(TRUE);
  142. }