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.

192 lines
5.2 KiB

  1. // --------------------------------------------------------------------------
  2. // Module Name: ShellServicesExports.cpp
  3. //
  4. // Copyright (c) 2001, Microsoft Corporation
  5. //
  6. // This file contains functions that exported from shsvcs.dll.
  7. //
  8. // History: 2001-01-02 vtan created
  9. // --------------------------------------------------------------------------
  10. #include "StandardHeader.h"
  11. #include "ServerAPI.h"
  12. #include "BAMService.h"
  13. #include "HDService.h"
  14. #include "ThemeService.h"
  15. HINSTANCE g_hInstance = NULL;
  16. // --------------------------------------------------------------------------
  17. // ::DllMain
  18. //
  19. // Arguments: See the platform SDK under DllMain.
  20. //
  21. // Returns: See the platform SDK under DllMain.
  22. //
  23. // Purpose: Performs initialization and clean up on process attach and
  24. // detach. Not interested in anything else.
  25. //
  26. // History: 2001-01-02 vtan created
  27. // --------------------------------------------------------------------------
  28. EXTERN_C BOOL WINAPI DllMain (HINSTANCE hInstance, DWORD fdwReason, LPVOID lpvReserved)
  29. {
  30. UNREFERENCED_PARAMETER(lpvReserved);
  31. NTSTATUS status;
  32. switch (fdwReason)
  33. {
  34. case DLL_PROCESS_ATTACH:
  35. g_hInstance = hInstance;
  36. status = CServerAPI::StaticInitialize();
  37. if (NT_SUCCESS(status))
  38. {
  39. status = CThemeService::Main(fdwReason);
  40. if (NT_SUCCESS(status))
  41. {
  42. status = CBAMService::Main(fdwReason);
  43. if (NT_SUCCESS(status))
  44. {
  45. CHDService::Main(fdwReason);
  46. }
  47. }
  48. }
  49. break;
  50. case DLL_PROCESS_DETACH:
  51. CHDService::Main(fdwReason);
  52. TSTATUS(CBAMService::Main(fdwReason));
  53. TSTATUS(CThemeService::Main(fdwReason));
  54. TSTATUS(CServerAPI::StaticTerminate());
  55. status = STATUS_SUCCESS;
  56. break;
  57. default:
  58. status = STATUS_SUCCESS;
  59. break;
  60. }
  61. return(NT_SUCCESS(status));
  62. }
  63. // --------------------------------------------------------------------------
  64. // ::DllInstall
  65. //
  66. // Arguments: <none>
  67. //
  68. // Returns: HRESULT
  69. //
  70. // Purpose:
  71. //
  72. // History: 2001-01-02 vtan created
  73. // --------------------------------------------------------------------------
  74. HRESULT WINAPI DllInstall (BOOL fInstall, LPCWSTR pszCmdLine)
  75. {
  76. return(CHDService::Install(fInstall, pszCmdLine));
  77. }
  78. // --------------------------------------------------------------------------
  79. // ::DllRegisterServer
  80. //
  81. // Arguments: <none>
  82. //
  83. // Returns: HRESULT
  84. //
  85. // Purpose: Register entry point to allow any service to install itself
  86. // into the registry.
  87. //
  88. // History: 2001-01-02 vtan created
  89. // --------------------------------------------------------------------------
  90. HRESULT WINAPI DllRegisterServer (void)
  91. {
  92. HRESULT hr;
  93. NTSTATUS status1, status2;
  94. status1 = CThemeService::RegisterServer();
  95. status2 = CBAMService::RegisterServer();
  96. hr = CHDService::RegisterServer();
  97. if (!NT_SUCCESS(status1))
  98. {
  99. hr = HRESULT_FROM_NT(status1);
  100. }
  101. else if (!NT_SUCCESS(status2))
  102. {
  103. hr = HRESULT_FROM_NT(status2);
  104. }
  105. return(hr);
  106. }
  107. // --------------------------------------------------------------------------
  108. // ::DllUnregisterServer
  109. //
  110. // Arguments: <none>
  111. //
  112. // Returns: HRESULT
  113. //
  114. // Purpose: Unregister entry point to allow any service to uninstall
  115. // itself from the registry.
  116. //
  117. // History: 2001-01-02 vtan created
  118. // --------------------------------------------------------------------------
  119. HRESULT WINAPI DllUnregisterServer (void)
  120. {
  121. HRESULT hr;
  122. NTSTATUS status1, status2;
  123. hr = CHDService::UnregisterServer();
  124. status2 = CBAMService::UnregisterServer();
  125. status1 = CThemeService::UnregisterServer();
  126. if (!NT_SUCCESS(status1))
  127. {
  128. hr = HRESULT_FROM_NT(status1);
  129. }
  130. else if (!NT_SUCCESS(status2))
  131. {
  132. hr = HRESULT_FROM_NT(status2);
  133. }
  134. return(hr);
  135. }
  136. // --------------------------------------------------------------------------
  137. // ::DllCanUnloadNow
  138. //
  139. // Arguments: See the platform SDK under DllMain.
  140. //
  141. // Returns: See the platform SDK under DllMain.
  142. //
  143. // Purpose: Returns whether the DLL can unload because there are no
  144. // outstanding COM object references.
  145. //
  146. // History: 2001-01-02 vtan created
  147. // --------------------------------------------------------------------------
  148. HRESULT WINAPI DllCanUnloadNow (void)
  149. {
  150. return(CHDService::CanUnloadNow());
  151. }
  152. // --------------------------------------------------------------------------
  153. // ::DllGetClassObject
  154. //
  155. // Arguments: See the platform SDK under DllMain.
  156. //
  157. // Returns: See the platform SDK under DllMain.
  158. //
  159. // Purpose: Returns a constructed COM object of the specified class.
  160. //
  161. // History: 2001-01-02 vtan created
  162. // --------------------------------------------------------------------------
  163. HRESULT WINAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, void** ppv)
  164. {
  165. return(CHDService::GetClassObject(rclsid, riid, ppv));
  166. }