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.

170 lines
4.1 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1998 **/
  4. /**********************************************************************/
  5. /*
  6. AcsAdmin.cpp
  7. Implements In-Proc Server for ACS User extension and ACS Admin Snapin
  8. FILE HISTORY:
  9. 11/03/97 Wei Jiang Created
  10. */
  11. // acsadmin.cpp : Implementation of DLL Exports.
  12. // Note: Proxy/Stub Information
  13. // To build a separate proxy/stub DLL,
  14. // run nmake -f acsadminps.mk in the project directory.
  15. #include "stdafx.h"
  16. #include "resource.h"
  17. #include "initguid.h"
  18. #include "acsadmin.h"
  19. #include "acsadmin_i.c"
  20. #include "ACSUser.h"
  21. #include "ACSSnap.h"
  22. #include "ACSSnapE.h"
  23. #include "ACSSnapA.h"
  24. // TFS snapin support
  25. #include "register.h"
  26. #include "tfsguid.h"
  27. #include "ncglobal.h" // network console global defines
  28. // ATL implementation code
  29. #include <atlimpl.cpp>
  30. // #include "DSObject.h"
  31. CComModule _Module;
  32. BEGIN_OBJECT_MAP(ObjectMap)
  33. #if 0 // user page is removed
  34. OBJECT_ENTRY(CLSID_ACSUser, CACSUser)
  35. #endif
  36. OBJECT_ENTRY(CLSID_ACSSnap, CACSSnap)
  37. OBJECT_ENTRY(CLSID_ACSSnapExt, CACSSnapExt)
  38. OBJECT_ENTRY(CLSID_ACSSnapAbout, CACSSnapAbout)
  39. // OBJECT_ENTRY(CLSID_DSObject, CDSObject)
  40. END_OBJECT_MAP()
  41. class CAcsadminApp : public CWinApp
  42. {
  43. public:
  44. virtual BOOL InitInstance();
  45. virtual int ExitInstance();
  46. };
  47. CAcsadminApp theApp;
  48. BOOL CAcsadminApp::InitInstance()
  49. {
  50. _Module.Init(ObjectMap, m_hInstance);
  51. return CWinApp::InitInstance();
  52. }
  53. int CAcsadminApp::ExitInstance()
  54. {
  55. _Module.Term();
  56. return CWinApp::ExitInstance();
  57. }
  58. /////////////////////////////////////////////////////////////////////////////
  59. // Used to determine whether the DLL can be unloaded by OLE
  60. STDAPI DllCanUnloadNow(void)
  61. {
  62. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  63. return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE;
  64. }
  65. /////////////////////////////////////////////////////////////////////////////
  66. // Returns a class factory to create an object of the requested type
  67. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  68. {
  69. return _Module.GetClassObject(rclsid, riid, ppv);
  70. }
  71. /////////////////////////////////////////////////////////////////////////////
  72. // DllRegisterServer - Adds entries to the system registry
  73. STDAPI DllRegisterServer(void)
  74. {
  75. TCHAR moduleFileName[MAX_PATH * 2];
  76. GetModuleFileNameOnly(_Module.GetModuleInstance(), moduleFileName, MAX_PATH * 2);
  77. //
  78. // registers object, typelib and all interfaces in typelib
  79. //
  80. HRESULT hr = _Module.RegisterServer(/* bRegTypeLib */ FALSE);
  81. ASSERT(SUCCEEDED(hr));
  82. CString name, NameStringIndirect;
  83. if (FAILED(hr))
  84. return hr;
  85. //
  86. // register the snapin into the console snapin list
  87. //
  88. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  89. name.LoadString(IDS_SNAPIN_DESC);
  90. NameStringIndirect.Format(L"@%s,-%-d", moduleFileName, IDS_SNAPIN_DESC);
  91. hr = RegisterSnapinGUID(&CLSID_ACSSnap,
  92. &CLSID_ACSRootNode,
  93. &CLSID_ACSSnapAbout,
  94. (LPCTSTR)name,
  95. _T("1.0"),
  96. TRUE,
  97. NameStringIndirect);
  98. ASSERT(SUCCEEDED(hr));
  99. if (FAILED(hr))
  100. return hr;
  101. #ifdef __NETWORK_CONSOLE__
  102. hr = RegisterAsRequiredExtensionGUID(&GUID_NetConsRootNodeType,
  103. &CLSID_ACSSnap,
  104. (LPCTSTR)name,
  105. EXTENSION_TYPE_TASK,
  106. &CLSID_ACSSnap);
  107. ASSERT(SUCCEEDED(hr));
  108. #endif
  109. return hr;
  110. }
  111. /////////////////////////////////////////////////////////////////////////////
  112. // DllUnregisterServer - Removes entries from the system registry
  113. STDAPI DllUnregisterServer(void)
  114. {
  115. HRESULT hr = _Module.UnregisterServer();
  116. ASSERT(SUCCEEDED(hr));
  117. if (FAILED(hr))
  118. return hr;
  119. // un register the snapin
  120. //
  121. hr = UnregisterSnapinGUID(&CLSID_ACSSnap);
  122. ASSERT(SUCCEEDED(hr));
  123. if (FAILED(hr))
  124. return hr;
  125. #ifdef __NETWORK_CONSOLE__
  126. hr = UnregisterAsExtensionGUID(&GUID_NetConsRootNodeType,
  127. &CLSID_ACSSnap,
  128. EXTENSION_TYPE_TASK);
  129. #endif
  130. return hr;
  131. }