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.

196 lines
4.6 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. rasuser.cpp
  7. Define and Implement the application class for RASUser component
  8. FILE HISTORY:
  9. */
  10. // Note: Proxy/Stub Information
  11. // To build a separate proxy/stub DLL,
  12. // run nmake -f Rasdialps.mk in the project directory.
  13. #include "stdafx.h"
  14. #include "resource.h"
  15. #include "initguid.h"
  16. #include "rasdial.h"
  17. #include "Dialin.h"
  18. #include "sharesdo.h"
  19. // tfscore -- for registering extension snapin
  20. #include "std.h"
  21. #include "compont.h"
  22. #include "compdata.h"
  23. #include "register.h"
  24. #include <atlimpl.cpp>
  25. CComModule _Module;
  26. DWORD g_dwTraceHandle = 0;
  27. BEGIN_OBJECT_MAP(ObjectMap)
  28. OBJECT_ENTRY(CLSID_RasDialin, CRasDialin)
  29. END_OBJECT_MAP()
  30. class CRasdialApp : public CWinApp
  31. {
  32. public:
  33. virtual BOOL InitInstance();
  34. virtual int ExitInstance();
  35. };
  36. CRasdialApp theApp;
  37. BOOL CRasdialApp::InitInstance()
  38. {
  39. _Module.Init(ObjectMap, m_hInstance);
  40. g_dwTraceHandle = TraceRegister(_T("rasuser"));
  41. TracePrintf(g_dwTraceHandle, _T("DLL Init"));
  42. g_pSdoServerPool = NULL;
  43. return CWinApp::InitInstance();
  44. }
  45. int CRasdialApp::ExitInstance()
  46. {
  47. TracePrintf(g_dwTraceHandle, _T("DLL Exit"));
  48. TraceDeregister(g_dwTraceHandle);
  49. _Module.Term();
  50. return CWinApp::ExitInstance();
  51. }
  52. /////////////////////////////////////////////////////////////////////////////
  53. // Used to determine whether the DLL can be unloaded by OLE
  54. STDAPI DllCanUnloadNow(void)
  55. {
  56. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  57. return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE;
  58. }
  59. /////////////////////////////////////////////////////////////////////////////
  60. // Returns a class factory to create an object of the requested type
  61. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  62. {
  63. return _Module.GetClassObject(rclsid, riid, ppv);
  64. }
  65. /////////////////////////////////////////////////////////////////////////////
  66. // DllRegisterServer - Adds entries to the system registry
  67. /* extern */ const CLSID CLSID_LocalUser =
  68. { /* 5d6179c8-17ec-11d1-9aa9-00c04fd8fe93 */
  69. 0x5d6179c8,
  70. 0x17ec,
  71. 0x11d1,
  72. {0x9a, 0xa9, 0x00, 0xc0, 0x4f, 0xd8, 0xfe, 0x93}
  73. };
  74. /* extern */ const GUID NODETYPE_User =
  75. { /* 5d6179cc-17ec-11d1-9aa9-00c04fd8fe93 */
  76. 0x5d6179cc,
  77. 0x17ec,
  78. 0x11d1,
  79. {0x9a, 0xa9, 0x00, 0xc0, 0x4f, 0xd8, 0xfe, 0x93}
  80. };
  81. /* extern */ const GUID NODETYPE_LocalSecRootFolder =
  82. { /* 5d6179d3-17ec-11d1-9aa9-00c04fd8fe93 */
  83. 0x5d6179d3,
  84. 0x17ec,
  85. 0x11d1,
  86. {0x9a, 0xa9, 0x00, 0xc0, 0x4f, 0xd8, 0xfe, 0x93}
  87. };
  88. /* extern */ const GUID NODETYPE_DsAdminDomain =
  89. { /* 19195a5b-6da0-11d0-afd3-00c04fd930c9 */
  90. 0x19195a5b,
  91. 0x6da0,
  92. 0x11d0,
  93. {0xaf, 0xd3, 0x00, 0xc0, 0x4f, 0xd9, 0x30, 0xc9}
  94. };
  95. STDAPI DllRegisterServer(void)
  96. {
  97. // registers object, typelib and all interfaces in typelib
  98. HRESULT hr = _Module.RegisterServer(TRUE);
  99. // registers the object with Admin property page for User Object
  100. #ifdef _REGDS
  101. if(S_OK == hr)
  102. hr = CRasDialin::RegisterAdminPropertyPage(true);
  103. #endif
  104. // register it as extension to localsecurity snapin
  105. //
  106. hr = RegisterSnapinGUID(&CLSID_RasDialin,
  107. &CLSID_RasDialin, // fake, no about for now
  108. &CLSID_RasDialin,
  109. _T("RAS Dialin - User Node Extension"),
  110. _T("1.0"),
  111. FALSE);
  112. ASSERT(SUCCEEDED(hr));
  113. hr = RegisterAsRequiredExtensionGUID(
  114. &NODETYPE_User,
  115. &CLSID_RasDialin,
  116. _T("Ras Dialin property page extension"),
  117. EXTENSION_TYPE_PROPERTYSHEET,
  118. NULL
  119. );
  120. ASSERT(SUCCEEDED(hr));
  121. #ifdef SINGLE_SDO_CONNECTION // for share the same sdo connection for multiple users
  122. hr = RegisterAsRequiredExtensionGUID(
  123. &NODETYPE_LocalSecRootFolder,
  124. &CLSID_RasDialin,
  125. _T("Ras Dialin property page extension"),
  126. EXTENSION_TYPE_NAMESPACE,
  127. NULL
  128. );
  129. ASSERT(SUCCEEDED(hr));
  130. hr = RegisterAsRequiredExtensionGUID(
  131. &NODETYPE_DsAdminDomain,
  132. &CLSID_RasDialin,
  133. _T("Ras Dialin property page extension"),
  134. EXTENSION_TYPE_NAMESPACE,
  135. NULL
  136. );
  137. #endif
  138. if(FAILED(hr))
  139. return SELFREG_E_CLASS;
  140. return S_OK;
  141. }
  142. /////////////////////////////////////////////////////////////////////////////
  143. // DllUnregisterServer - Removes entries from the system registry
  144. STDAPI DllUnregisterServer(void)
  145. {
  146. _Module.UnregisterServer();
  147. #ifdef _REGDS
  148. if(FAILED(CRasDialin::RegisterAdminPropertyPage(false)))
  149. return SELFREG_E_CLASS;
  150. #endif
  151. return S_OK;
  152. }