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.

236 lines
5.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1997.
  5. //
  6. // File: libmain.cxx
  7. //
  8. // Contents: DllMain for csadm.dll
  9. //
  10. // Functions: DllMain, DllGetClassObject
  11. //
  12. // History: 05-May-97 DebiM Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "csadm.hxx"
  16. #pragma hdrstop
  17. // Globals
  18. HINSTANCE g_hInst = NULL;
  19. ULONG g_ulObjCount = 0; // Number of objects alive in csadm.dll
  20. CClassContainerCF *g_pCF = NULL;
  21. void Uninit()
  22. //
  23. // This routine is called at dll detach time
  24. //
  25. {
  26. //
  27. // release the Class Factory object
  28. //
  29. if (g_pCF)
  30. g_pCF->Release();
  31. }
  32. //+---------------------------------------------------------------
  33. //
  34. // Function: DllGetClassObject
  35. //
  36. // Synopsis: Standard DLL entrypoint for locating class factories
  37. //
  38. //----------------------------------------------------------------
  39. STDAPI
  40. DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID FAR* ppv)
  41. {
  42. HRESULT hr;
  43. size_t i;
  44. if (IsEqualCLSID(clsid, CLSID_DirectoryClassBase))
  45. {
  46. return g_pCF->QueryInterface(iid, ppv);
  47. }
  48. *ppv = NULL;
  49. return E_NOINTERFACE;
  50. }
  51. //+---------------------------------------------------------------
  52. //
  53. // Function: DllCanUnloadNow
  54. //
  55. // Synopsis: Standard DLL entrypoint to determine if DLL can be unloaded
  56. //
  57. //---------------------------------------------------------------
  58. STDAPI
  59. DllCanUnloadNow(void)
  60. {
  61. HRESULT hr;
  62. hr = S_FALSE;
  63. //
  64. // BugBug
  65. //
  66. /*
  67. if (ulObjectCount > 0)
  68. hr = S_FALSE;
  69. else
  70. hr = S_OK;
  71. */
  72. return hr;
  73. }
  74. //+---------------------------------------------------------------
  75. //
  76. // Function: LibMain
  77. //
  78. // Synopsis: Standard DLL initialization entrypoint
  79. //
  80. //---------------------------------------------------------------
  81. EXTERN_C BOOL __cdecl
  82. LibMain(HINSTANCE hInst, ULONG ulReason, LPVOID pvReserved)
  83. {
  84. HRESULT hr;
  85. DWORD cbSize = _MAX_PATH;
  86. WCHAR wszUserName [_MAX_PATH];
  87. switch (ulReason)
  88. {
  89. case DLL_PROCESS_ATTACH:
  90. DisableThreadLibraryCalls(hInst);
  91. g_hInst = hInst;
  92. g_pCF = new CClassContainerCF;
  93. break;
  94. case DLL_PROCESS_DETACH:
  95. Uninit();
  96. break;
  97. default:
  98. break;
  99. }
  100. return TRUE;
  101. }
  102. //+---------------------------------------------------------------------------
  103. //
  104. // Function: DllMain
  105. //
  106. // Synopsis: entry point for NT
  107. //
  108. //----------------------------------------------------------------------------
  109. BOOL
  110. DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
  111. {
  112. return LibMain((HINSTANCE)hDll, dwReason, lpReserved);
  113. }
  114. //+---------------------------------------------------------------
  115. //
  116. // Function: CsCreateClassStore
  117. //
  118. // Synopsis: Public entrypoint for creating an empty class store. factories
  119. //
  120. //----------------------------------------------------------------
  121. STDAPI
  122. CsCreateClassStore(LPOLESTR szParentPath, LPOLESTR szStoreName)
  123. {
  124. LPOLESTR szPath;
  125. if (wcsncmp (szParentPath, L"ADCS:", 5) == 0)
  126. szPath = szParentPath + 5;
  127. else
  128. szPath = szParentPath;
  129. return CreateRepository(szPath, szStoreName);
  130. }
  131. //+---------------------------------------------------------------
  132. //
  133. // Function: CsGetClassStore
  134. //
  135. // Synopsis: Public entrypoint for binding to a class store and
  136. // get back IClassAdmin
  137. //
  138. //----------------------------------------------------------------
  139. STDAPI
  140. CsGetClassStore(LPOLESTR szPath, void **ppIClassAdmin)
  141. {
  142. return g_pCF->CreateConnectedInstance(
  143. szPath,
  144. ppIClassAdmin);
  145. }
  146. //+---------------------------------------------------------------
  147. //
  148. // Function: CsDeleteClassStore
  149. //
  150. // Synopsis: Public entrypoint for deleting a class store container from DS.
  151. //
  152. //----------------------------------------------------------------
  153. STDAPI
  154. CsDeleteClassStore(LPOLESTR szPath)
  155. {
  156. return E_NOTIMPL;
  157. }
  158. //+-------------------------------------------------------------------
  159. //
  160. // CsGetAppCategories
  161. //
  162. // Returns the complete list of Category GUIDs and Category Descriptions
  163. // per the input Locale.
  164. //
  165. //
  166. // This is used by Add/Remove programs to get the definitive list of
  167. // Application Categories.
  168. //
  169. // The caller needs to free the memory allocated using CoTaskMemFree().
  170. //
  171. // Arguments:
  172. // [in]
  173. // LCID : Locale
  174. // [out]
  175. // APPCATEGORYINFOLIST *pAppCategoryList:
  176. // Returned list of GUIDs and Unicode descriptions
  177. //
  178. // Returns :
  179. // S_OK
  180. //
  181. //--------------------------------------------------------------------
  182. STDAPI
  183. CsGetAppCategories (APPCATEGORYINFOLIST *pAppCategoryList)
  184. {
  185. HRESULT hr;
  186. IClassAdmin * pIClassAdmin = NULL;
  187. hr = g_pCF->CreateInstance(
  188. NULL,
  189. IID_IClassAdmin,
  190. (void **)&pIClassAdmin);
  191. if (!SUCCEEDED(hr))
  192. return hr;
  193. hr = pIClassAdmin->GetAppCategories (
  194. GetUserDefaultLCID(),
  195. pAppCategoryList);
  196. pIClassAdmin->Release();
  197. return hr;
  198. }