Leaked source code of windows server 2003
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.

181 lines
5.0 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. rtrui.cpp
  7. FILE HISTORY:
  8. */
  9. #include "stdafx.h"
  10. #include "tfschar.h"
  11. #include "info.h"
  12. #include "rtrui.h"
  13. #include "add.h" // dialogs
  14. #include "rtrstr.h"
  15. #include "tregkey.h"
  16. #include "reg.h" // Connect/DisconnectRegistry
  17. //----------------------------------------------------------------------------
  18. // Function: AddRmInterfacePrompt
  19. //
  20. // Prompts the user to select from a list of the interfaces on which
  21. // a specified router-manager can be enabled.
  22. //
  23. // Returns TRUE if the user selects an interface, FALSE otherwise.
  24. //
  25. // If the user selects an interface, then on output 'ppRmInterfaceInfo'
  26. // will contain a pointer to a 'CRmInterfaceInfo' describing the interface
  27. // selected by the user.
  28. //----------------------------------------------------------------------------
  29. BOOL
  30. AddRmInterfacePrompt(
  31. IN IRouterInfo* pRouterInfo,
  32. IN IRtrMgrInfo* pRmInfo,
  33. OUT IRtrMgrInterfaceInfo** ppRmInterfaceInfo,
  34. IN CWnd* pParent
  35. ) {
  36. //
  37. // Construct and display the interfaces dialog.
  38. //
  39. CRmAddInterface dlg(pRouterInfo, pRmInfo, ppRmInterfaceInfo, pParent);
  40. if (dlg.DoModal() != IDOK) { return FALSE; }
  41. return TRUE;
  42. }
  43. //----------------------------------------------------------------------------
  44. // Function: CreateRtrLibImageList
  45. //
  46. // Creates an imagelist containing images from the resource 'IDB_IMAGELIST'.
  47. //----------------------------------------------------------------------------
  48. BOOL
  49. CreateRtrLibImageList(
  50. IN CImageList* imageList
  51. ) {
  52. return imageList->Create(
  53. MAKEINTRESOURCE(IDB_RTRLIB_IMAGELIST), 16, 0, PALETTEINDEX(6)
  54. );
  55. }
  56. //----------------------------------------------------------------------------
  57. // Function: AddRmProtInterfacePrompt
  58. //
  59. // Prompts the user to select from a list of the interfaces on which
  60. // a specified routing-protocol can be enabled.
  61. //
  62. // Returns TRUE if the user selects an interface, FALSE otherwise.
  63. //
  64. // If the user selects an interface, then on output 'ppRmInterfaceInfo'
  65. // will contain a pointer to a 'CRmInterfaceInfo' describing the interface
  66. // selected by the user.
  67. //
  68. // Requires common.rc.
  69. //----------------------------------------------------------------------------
  70. BOOL
  71. AddRmProtInterfacePrompt(
  72. IN IRouterInfo* pRouterInfo,
  73. IN IRtrMgrProtocolInfo* pRmProtInfo,
  74. OUT IRtrMgrProtocolInterfaceInfo** ppRmProtInterfaceInfo,
  75. IN CWnd* pParent)
  76. {
  77. //
  78. // Construct and display the interfaces dialog.
  79. //
  80. CRpAddInterface dlg(pRouterInfo, pRmProtInfo, ppRmProtInterfaceInfo, pParent);
  81. if (dlg.DoModal() != IDOK) { return FALSE; }
  82. return TRUE;
  83. }
  84. BOOL
  85. AddProtocolPrompt(IN IRouterInfo *pRouter,
  86. IN IRtrMgrInfo *pRm,
  87. IN IRtrMgrProtocolInfo **ppRmProt,
  88. IN CWnd *pParent)
  89. {
  90. //
  91. // Construct and display the routing-protocol dialog.
  92. //
  93. CAddRoutingProtocol dlg(pRouter, pRm, ppRmProt, pParent);
  94. if (dlg.DoModal() != IDOK) { return FALSE; }
  95. return TRUE;
  96. }
  97. static unsigned int s_cfComputerAddedAsLocal = RegisterClipboardFormat(L"MMC_MPRSNAP_COMPUTERADDEDASLOCAL");
  98. BOOL ExtractComputerAddedAsLocal(LPDATAOBJECT lpDataObject)
  99. {
  100. BOOL fReturn = FALSE;
  101. BOOL * pReturn;
  102. pReturn = Extract<BOOL>(lpDataObject, (CLIPFORMAT) s_cfComputerAddedAsLocal, -1);
  103. if (pReturn)
  104. {
  105. fReturn = *pReturn;
  106. GlobalFree(pReturn);
  107. }
  108. return fReturn;
  109. }
  110. /*!--------------------------------------------------------------------------
  111. NatConflictExists
  112. Returns TRUE if SharedAccess is already running on the specified
  113. machine.
  114. Author: AboladeG
  115. ---------------------------------------------------------------------------*/
  116. BOOL NatConflictExists(LPCTSTR lpszMachine)
  117. {
  118. SC_HANDLE hScm;
  119. SC_HANDLE hSharedAccess;
  120. BOOL fReturn = FALSE;
  121. SERVICE_STATUS serviceStatus;
  122. hScm = OpenSCManager(lpszMachine, SERVICES_ACTIVE_DATABASE, GENERIC_READ);
  123. if (hScm)
  124. {
  125. hSharedAccess = OpenService(hScm, c_szSharedAccessService, GENERIC_READ);
  126. if (hSharedAccess)
  127. {
  128. if (QueryServiceStatus(hSharedAccess, &serviceStatus))
  129. {
  130. if (SERVICE_RUNNING == serviceStatus.dwCurrentState
  131. || SERVICE_START_PENDING == serviceStatus.dwCurrentState)
  132. {
  133. fReturn = TRUE;
  134. }
  135. }
  136. CloseServiceHandle(hSharedAccess);
  137. }
  138. CloseServiceHandle(hScm);
  139. }
  140. return fReturn;
  141. }