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.

1844 lines
45 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ClusCfg.cpp
  7. //
  8. // Description:
  9. // Implementation of CClusCfgWizard class.
  10. //
  11. // Maintained By:
  12. // David Potter (DavidP) 14-MAR_2001
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. //////////////////////////////////////////////////////////////////////////////
  16. // Include Files
  17. //////////////////////////////////////////////////////////////////////////////
  18. #include "Pch.h"
  19. // #include "ClusCfg.h" -- in the PCH.H
  20. #include "TaskTreeView.h"
  21. #include "AnalyzePage.h"
  22. #include "CheckingAccessPage.h"
  23. #include "ClusDomainPage.h"
  24. #include "CommitPage.h"
  25. #include "CompletionPage.h"
  26. #include "CredLoginPage.h"
  27. #include "CSAccountPage.h"
  28. #include "IPAddressPage.h"
  29. #include "SelNodePage.h"
  30. #include "SelNodesPage.h"
  31. #include "WelcomePage.h"
  32. #include "SummaryPage.h"
  33. //****************************************************************************
  34. //
  35. // CClusCfgWizard
  36. //
  37. //****************************************************************************
  38. DEFINE_THISCLASS( "CClusCfgWizard" )
  39. //////////////////////////////////////////////////////////////////////////////
  40. //++
  41. //
  42. // static
  43. // HRESULT
  44. // CClusCfgWizard::S_HrCreateInstance(
  45. // IUnknown ** ppunkOut
  46. // )
  47. //
  48. // Description:
  49. // Create a CClusCfgWizard instance.
  50. //
  51. // Arguments:
  52. // None.
  53. //
  54. // Return Values:
  55. // Pointer to CClusCfgWizard instance.
  56. //
  57. //--
  58. //////////////////////////////////////////////////////////////////////////////
  59. HRESULT
  60. CClusCfgWizard::S_HrCreateInstance(
  61. IUnknown ** ppunkOut
  62. )
  63. {
  64. TraceFunc( "" );
  65. Assert( ppunkOut != NULL );
  66. HRESULT hr;
  67. CClusCfgWizard * pClusCfgWizard;
  68. pClusCfgWizard = new CClusCfgWizard();
  69. if ( pClusCfgWizard != NULL )
  70. {
  71. hr = THR( pClusCfgWizard->HrInit() );
  72. if ( SUCCEEDED( hr ) )
  73. {
  74. hr = THR( pClusCfgWizard->TypeSafeQI( IUnknown, ppunkOut ) );
  75. }
  76. pClusCfgWizard->Release( );
  77. }
  78. else
  79. {
  80. hr = E_OUTOFMEMORY;
  81. }
  82. HRETURN( hr );
  83. } //*** CClusCfgWizard::S_HrCreateInstance()
  84. //////////////////////////////////////////////////////////////////////////////
  85. //++
  86. //
  87. // CClusCfgWizard::CClusCfgWizard( )
  88. //
  89. //--
  90. //////////////////////////////////////////////////////////////////////////////
  91. CClusCfgWizard::CClusCfgWizard( )
  92. {
  93. TraceFunc( "" );
  94. TraceFuncExit( );
  95. } // CClusCfgWizard( )
  96. //////////////////////////////////////////////////////////////////////////////
  97. //++
  98. //
  99. // CClusCfgWizard::~CClusCfgWizard( )
  100. //
  101. //--
  102. //////////////////////////////////////////////////////////////////////////////
  103. CClusCfgWizard::~CClusCfgWizard( )
  104. {
  105. TraceFunc( "" );
  106. if ( m_bstrClusterName != NULL )
  107. {
  108. TraceSysFreeString( m_bstrClusterName );
  109. }
  110. if ( m_bstrAccountName != NULL )
  111. {
  112. TraceSysFreeString( m_bstrAccountName );
  113. }
  114. if ( m_bstrPassword != NULL )
  115. {
  116. TraceSysFreeString( m_bstrPassword );
  117. }
  118. if ( m_bstrDomain != NULL )
  119. {
  120. TraceSysFreeString( m_bstrDomain );
  121. }
  122. if ( m_bstrNetworkName != NULL )
  123. {
  124. TraceSysFreeString( m_bstrNetworkName );
  125. }
  126. if ( m_rgbstrComputers != NULL )
  127. {
  128. while( m_cComputers != 0 )
  129. {
  130. m_cComputers--;
  131. TraceSysFreeString( m_rgbstrComputers[ m_cComputers ] );
  132. }
  133. TraceFree( m_rgbstrComputers );
  134. }
  135. if ( m_psp != NULL )
  136. {
  137. m_psp->Release( );
  138. }
  139. if ( m_hRichEdit != NULL )
  140. {
  141. FreeLibrary( m_hRichEdit );
  142. }
  143. TraceFuncExit( );
  144. } // ~CClusCfgWizard( )
  145. //////////////////////////////////////////////////////////////////////////////
  146. //
  147. // HRESULT
  148. // CClusCfgWizard::HrInit( void )
  149. //
  150. // Description:
  151. // Initialize a CClusCfgWizard instance.
  152. //
  153. // Arguments:
  154. // None.
  155. //
  156. // Return Values:
  157. // S_OK
  158. //
  159. //////////////////////////////////////////////////////////////////////////////
  160. HRESULT
  161. CClusCfgWizard::HrInit( void )
  162. {
  163. HRESULT hr = S_OK;
  164. TraceFunc( "" );
  165. INITCOMMONCONTROLSEX icex;
  166. BOOL bRet;
  167. HMODULE hRichEdit;
  168. Assert( m_cRef == 0 );
  169. AddRef();
  170. Assert( m_bstrClusterName == NULL );
  171. Assert( m_bstrAccountName == NULL );
  172. Assert( m_bstrPassword == NULL );
  173. Assert( m_bstrDomain == NULL );
  174. Assert( m_ulIPAddress == 0 );
  175. Assert( m_ulIPSubnet == 0 );
  176. Assert( m_bstrNetworkName == NULL );
  177. Assert( m_cComputers == 0 );
  178. Assert( m_cArraySize == 0 );
  179. Assert( m_rgbstrComputers == NULL );
  180. icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
  181. icex.dwICC = ICC_INTERNET_CLASSES
  182. | ICC_PROGRESS_CLASS
  183. | ICC_TREEVIEW_CLASSES
  184. | ICC_LISTVIEW_CLASSES;
  185. bRet = InitCommonControlsEx( &icex );
  186. Assert( bRet != FALSE );
  187. hr = THR( CoCreateInstance( CLSID_ServiceManager,
  188. NULL,
  189. CLSCTX_INPROC_SERVER,
  190. IID_IServiceProvider,
  191. reinterpret_cast< void ** >( &m_psp )
  192. ) );
  193. if ( FAILED( hr ) )
  194. goto Cleanup;
  195. //
  196. // Initialize the RichEdit controls.
  197. //
  198. m_hRichEdit = LoadLibrary( L"RichEd32.Dll" );
  199. if ( m_hRichEdit == NULL )
  200. {
  201. hr = HRESULT_FROM_WIN32( TW32( GetLastError( ) ) );
  202. goto Cleanup;
  203. }
  204. Cleanup:
  205. HRETURN( hr );
  206. } //*** CClusCfgWizard::HrInit()
  207. //****************************************************************************
  208. //
  209. // IUnknown
  210. //
  211. //****************************************************************************
  212. //////////////////////////////////////////////////////////////////////////////
  213. //++
  214. //
  215. // STDMETHODIMP
  216. // [IUnknown] CClusCfgWizard::QueryInterface(
  217. // REFIID riidIn,
  218. // PVOID * ppvOut
  219. // )
  220. //
  221. // Description:
  222. //
  223. // Arguments:
  224. // riidIn
  225. // ppvOut
  226. //
  227. // Return Values:
  228. // NOERROR
  229. // E_NOINTERFACE
  230. //
  231. //--
  232. //////////////////////////////////////////////////////////////////////////////
  233. STDMETHODIMP
  234. CClusCfgWizard::QueryInterface(
  235. REFIID riidIn,
  236. PVOID * ppvOut
  237. )
  238. {
  239. TraceQIFunc( riidIn, ppvOut );
  240. HRESULT hr = E_NOINTERFACE;
  241. if ( IsEqualIID( riidIn, IID_IUnknown ) )
  242. {
  243. *ppvOut = static_cast< IClusCfgWizard * >( this );
  244. hr = S_OK;
  245. } // if: IUnknown
  246. else if ( IsEqualIID( riidIn, IID_IDispatch )
  247. || IsEqualIID( riidIn, IID_IClusCfgWizard )
  248. )
  249. {
  250. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgWizard, this, 0 );
  251. hr = S_OK;
  252. } // else if: IDispatch || IClusCfgWizard
  253. if ( SUCCEEDED( hr ) )
  254. {
  255. ((IUnknown*) *ppvOut)->AddRef( );
  256. } // if: success
  257. QIRETURN_IGNORESTDMARSHALLING( hr, riidIn );
  258. } //*** CClusCfgWizard::QueryInterface()
  259. //////////////////////////////////////////////////////////////////////////////
  260. //++
  261. //
  262. // STDMETHODIMP_( ULONG )
  263. // [IUnknown] CClusCfgWizard::AddRef( void )
  264. //
  265. // Description:
  266. //
  267. // Arguments:
  268. // None.
  269. //
  270. // Return Values:
  271. // New reference count.
  272. //
  273. //--
  274. //////////////////////////////////////////////////////////////////////////////
  275. STDMETHODIMP_( ULONG )
  276. CClusCfgWizard::AddRef( void )
  277. {
  278. TraceFunc( "[IUnknown]" );
  279. // Apartment object - interlocked not needed.
  280. m_cRef++;
  281. RETURN( m_cRef );
  282. } //*** CClusCfgWizard::AddRef()
  283. //////////////////////////////////////////////////////////////////////////////
  284. //++
  285. //
  286. // STDMETHODIMP_( ULONG )
  287. // [IUnknown] CClusCfgWizard::Release( void )
  288. //
  289. // Description:
  290. //
  291. // Arguments:
  292. // None.
  293. //
  294. // Return Values:
  295. // New reference count.
  296. //
  297. //////////////////////////////////////////////////////////////////////////////
  298. STDMETHODIMP_( ULONG )
  299. CClusCfgWizard::Release( void )
  300. {
  301. TraceFunc( "[IUnknown]" );
  302. // Apartment object - interlocked not needed.
  303. m_cRef--;
  304. if ( m_cRef == 0 )
  305. {
  306. delete this;
  307. RETURN( 0 );
  308. }
  309. RETURN( m_cRef );
  310. } //*** CClusCfgWizard::Release()
  311. //****************************************************************************
  312. //
  313. // IClusCfgWizard
  314. //
  315. //****************************************************************************
  316. //////////////////////////////////////////////////////////////////////////
  317. //++
  318. //
  319. // STDMETHODIMP
  320. // CClusCfgWizard::CreateCluster(
  321. // LONG ParentWnd,
  322. // BOOL * pfDone
  323. // )
  324. //
  325. //--
  326. //////////////////////////////////////////////////////////////////////////
  327. STDMETHODIMP
  328. CClusCfgWizard::CreateCluster(
  329. HWND lParentWndIn,
  330. BOOL * pfDoneOut
  331. )
  332. {
  333. TraceFunc( "[IClusCfgWizard]" );
  334. HPROPSHEETPAGE rPages[ 11 ];
  335. PROPSHEETHEADER pshead;
  336. BOOL fShowCredentialPage;
  337. BOOL fSuccess;
  338. INT_PTR ipStatus;
  339. HRESULT hr = S_OK;
  340. ILogManager * plm = NULL;
  341. CWelcomePage dlgWelcomePage( camCREATING );
  342. CClusDomainPage dlgClusDomainPage( m_psp, camCREATING, &m_bstrClusterName, IDS_DOMAIN_DESC_CREATE );
  343. CCheckingAccessPage dlgCheckingAccessPage( m_psp, &m_bstrClusterName, &fShowCredentialPage );
  344. CCredLoginPage dlgCredLoginPage( m_psp, &m_bstrClusterName, &fShowCredentialPage );
  345. CSelNodePage dlgSelNodePage( m_psp, camCREATING, &m_cComputers, &m_rgbstrComputers, &m_bstrClusterName );
  346. CAnalyzePage dlgAnalyzePage( m_psp, camCREATING, &m_cComputers, &m_rgbstrComputers, &m_bstrClusterName );
  347. CIPAddressPage dlgIPAddressPage( m_psp, camCREATING, &m_ulIPAddress, &m_ulIPSubnet, &m_bstrNetworkName, &m_bstrClusterName );
  348. CCSAccountPage dlgCSAccountPage( m_psp, camCREATING, &m_bstrAccountName, &m_bstrPassword, &m_bstrDomain, &m_bstrClusterName );
  349. CSummaryPage dlgSummaryPage( m_psp, camCREATING, &m_bstrClusterName, IDS_SUMMARY_NEXT_CREATE );
  350. CCommitPage dlgCommitPage( m_psp, camCREATING, &m_bstrClusterName );
  351. CCompletionPage dlgCompletionPage( IDS_COMPLETION_TITLE_CREATE, IDS_COMPLETION_DESC_CREATE );
  352. //
  353. // TODO: gpease 14-MAY-2000
  354. // Do we really need this?
  355. //
  356. if ( pfDoneOut == NULL )
  357. goto InvalidPointer;
  358. //
  359. // Start the logger.
  360. //
  361. hr = THR( m_psp->TypeSafeQS( CLSID_LogManager,
  362. ILogManager,
  363. &plm
  364. ) );
  365. if ( FAILED( hr ) )
  366. goto Cleanup;
  367. hr = THR( plm->StartLogging() );
  368. if ( FAILED( hr ) )
  369. goto Cleanup;
  370. //
  371. // Create the Wizard.
  372. //
  373. ZeroMemory( &pshead, sizeof( pshead ) );
  374. pshead.dwSize = sizeof( pshead );
  375. pshead.dwFlags = PSH_WIZARD97 | PSH_WATERMARK | PSH_HEADER;
  376. pshead.hInstance = g_hInstance;
  377. pshead.pszCaption = MAKEINTRESOURCE( IDS_TITLE_FORM );
  378. pshead.phpage = rPages;
  379. pshead.pszbmWatermark = MAKEINTRESOURCE( IDB_WATERMARK );
  380. pshead.pszbmHeader = MAKEINTRESOURCE( IDB_BANNER );
  381. pshead.hwndParent = lParentWndIn;
  382. THR( HrAddWizardPage( &pshead, IDD_WELCOME_CREATE, CWelcomePage::S_DlgProc, 0, 0, (LPARAM) &dlgWelcomePage ) );
  383. THR( HrAddWizardPage( &pshead, IDD_CLUSDOMAIN, CClusDomainPage::S_DlgProc, IDS_TCLUSTER, IDS_STCLUSTER_CREATE, (LPARAM) &dlgClusDomainPage ) );
  384. THR( HrAddWizardPage( &pshead, IDD_CHECKINGACCESS, CCheckingAccessPage::S_DlgProc, IDS_TCHECKINGACCESS, IDS_STCHECKINGACCESS, (LPARAM) &dlgCheckingAccessPage ) );
  385. THR( HrAddWizardPage( &pshead, IDD_CREDLOGIN, CCredLoginPage::S_DlgProc, IDS_TCREDLOGIN, IDS_STCREDLOGIN, (LPARAM) &dlgCredLoginPage ) );
  386. THR( HrAddWizardPage( &pshead, IDD_SELNODE, CSelNodePage::S_DlgProc, IDS_TSELNODE, IDS_STSELNODE, (LPARAM) &dlgSelNodePage ) );
  387. THR( HrAddWizardPage( &pshead, IDD_ANALYZE, CAnalyzePage::S_DlgProc, IDS_TANALYZE, IDS_STANALYZE, (LPARAM) &dlgAnalyzePage ) );
  388. THR( HrAddWizardPage( &pshead, IDD_IPADDRESS, CIPAddressPage::S_DlgProc, IDS_TIPADDRESS, IDS_STIPADDRESS, (LPARAM) &dlgIPAddressPage ) );
  389. THR( HrAddWizardPage( &pshead, IDD_CSACCOUNT, CCSAccountPage::S_DlgProc, IDS_TCSACCOUNT, IDS_STCSACCOUNT, (LPARAM) &dlgCSAccountPage ) );
  390. THR( HrAddWizardPage( &pshead, IDD_SUMMARY, CSummaryPage::S_DlgProc, IDS_TSUMMARY, IDS_STSUMMARY_CREATE, (LPARAM) &dlgSummaryPage ) );
  391. THR( HrAddWizardPage( &pshead, IDD_COMMIT, CCommitPage::S_DlgProc, IDS_TCOMMIT_CREATE, IDS_STCOMMIT, (LPARAM) &dlgCommitPage ) );
  392. THR( HrAddWizardPage( &pshead, IDD_COMPLETION, CCompletionPage::S_DlgProc, 0, 0, (LPARAM) &dlgCompletionPage ) );
  393. AssertMsg( pshead.nPages == ARRAYSIZE( rPages ), "Not enough or too many PROPSHEETPAGEs." );
  394. ipStatus = PropertySheet( &pshead );
  395. if ( ipStatus == -1 )
  396. {
  397. TW32( GetLastError( ) );
  398. }
  399. fSuccess = ipStatus != NULL;
  400. if ( pfDoneOut != NULL )
  401. {
  402. *pfDoneOut = fSuccess;
  403. }
  404. Cleanup:
  405. if ( plm != NULL )
  406. {
  407. THR( plm->StopLogging() );
  408. plm->Release();
  409. }
  410. HRETURN( hr );
  411. InvalidPointer:
  412. hr = THR( E_POINTER );
  413. goto Cleanup;
  414. } //*** CClusCfgWizard::CreateCluster()
  415. //////////////////////////////////////////////////////////////////////////
  416. //++
  417. //
  418. // STDMETHODIMP
  419. // CClusCfgWizard::AddClusterNodes(
  420. // /*[in, defaultvalue(0)]*/ LONG lParentWndIn,
  421. // /*[out, retval]*/ BOOL * pfDoneOut
  422. // )
  423. //
  424. // Description:
  425. // Launch the Cluster Wizard in Add Cluster Nodes mode.
  426. //
  427. // Parameters
  428. // ParentWnd - Handle to the parent window (default NULL).
  429. // If not NULL, the wizard will be positionned
  430. // in the center of this window.
  431. // Done - return TRUE if committed, FALSE if cancelled.
  432. //
  433. // Return Values:
  434. // S_OK - The call succeeded.
  435. // other HRESULTs - The call failed.
  436. // E_POINTER
  437. // E_FAIL
  438. // E_OUTOFMEMORY
  439. //
  440. //////////////////////////////////////////////////////////////////////////
  441. STDMETHODIMP
  442. CClusCfgWizard::AddClusterNodes(
  443. HWND lParentWndIn,
  444. BOOL * pfDoneOut
  445. )
  446. {
  447. TraceFunc( "[IClusCfgWizard]" );
  448. HPROPSHEETPAGE rPages[ 10 ];
  449. PROPSHEETHEADER pshead;
  450. BOOL fShowCredentialPage;
  451. BOOL fSuccess;
  452. INT_PTR ipStatus;
  453. HRESULT hr = S_OK;
  454. ILogManager * plm = NULL;
  455. OBJECTCOOKIE cookieDummy;
  456. CWelcomePage dlgWelcomePage( camADDING );
  457. CClusDomainPage dlgClusDomainPage( m_psp, camADDING, &m_bstrClusterName, IDS_DOMAIN_DESC_ADD );
  458. CCheckingAccessPage dlgCheckingAccessPage( m_psp, &m_bstrClusterName, &fShowCredentialPage );
  459. CCredLoginPage dlgCredLoginPage( m_psp, &m_bstrClusterName, &fShowCredentialPage );
  460. CSelNodesPage dlgSelNodesPage( m_psp, camADDING, &m_cComputers, &m_rgbstrComputers, &m_bstrClusterName );
  461. CAnalyzePage dlgAnalyzePage( m_psp, camADDING, &m_cComputers, &m_rgbstrComputers, &m_bstrClusterName );
  462. CCSAccountPage dlgCSAccountPage( m_psp, camADDING, &m_bstrAccountName, &m_bstrPassword, &m_bstrDomain, &m_bstrClusterName );
  463. CSummaryPage dlgSummaryPage( m_psp, camADDING, &m_bstrClusterName, IDS_SUMMARY_NEXT_ADD );
  464. CCommitPage dlgCommitPage( m_psp, camADDING, &m_bstrClusterName );
  465. CCompletionPage dlgCompletionPage( IDS_COMPLETION_TITLE_ADD, IDS_COMPLETION_DESC_ADD );
  466. //
  467. // TODO: gpease 12-JUL-2000
  468. // Do we really need this? Or can we have the script implement an event
  469. // sink that we signal?
  470. //
  471. if ( pfDoneOut == NULL )
  472. goto InvalidPointer;
  473. //
  474. // Start the logger.
  475. //
  476. hr = THR( m_psp->TypeSafeQS( CLSID_LogManager,
  477. ILogManager,
  478. &plm
  479. ) );
  480. if ( FAILED( hr ) )
  481. goto Cleanup;
  482. hr = THR( plm->StartLogging() );
  483. if ( FAILED( hr ) )
  484. goto Cleanup;
  485. //
  486. // Create the Wizard.
  487. //
  488. ZeroMemory( &pshead, sizeof(pshead) );
  489. pshead.dwSize = sizeof(pshead);
  490. pshead.dwFlags = PSH_WIZARD97 | PSH_WATERMARK | PSH_HEADER;
  491. pshead.hInstance = g_hInstance;
  492. pshead.pszCaption = MAKEINTRESOURCE( IDS_TITLE_JOIN );
  493. pshead.phpage = rPages;
  494. pshead.pszbmWatermark = MAKEINTRESOURCE( IDB_WATERMARK );
  495. pshead.pszbmHeader = MAKEINTRESOURCE( IDB_BANNER );
  496. pshead.hwndParent = lParentWndIn;
  497. THR( HrAddWizardPage( &pshead, IDD_WELCOME_ADD, CWelcomePage::S_DlgProc, 0, 0, (LPARAM) &dlgWelcomePage ) );
  498. THR( HrAddWizardPage( &pshead, IDD_CLUSDOMAIN, CClusDomainPage::S_DlgProc, IDS_TCLUSTER, IDS_STCLUSTER_ADD, (LPARAM) &dlgClusDomainPage ) );
  499. THR( HrAddWizardPage( &pshead, IDD_CHECKINGACCESS, CCheckingAccessPage::S_DlgProc, IDS_TCHECKINGACCESS, IDS_STCHECKINGACCESS, (LPARAM) &dlgCheckingAccessPage ) );
  500. THR( HrAddWizardPage( &pshead, IDD_CREDLOGIN, CCredLoginPage::S_DlgProc, IDS_TCREDLOGIN, IDS_STCREDLOGIN, (LPARAM) &dlgCredLoginPage ) );
  501. THR( HrAddWizardPage( &pshead, IDD_SELNODES, CSelNodesPage::S_DlgProc, IDS_TSELNODES, IDS_STSELNODES, (LPARAM) &dlgSelNodesPage ) );
  502. THR( HrAddWizardPage( &pshead, IDD_ANALYZE, CAnalyzePage::S_DlgProc, IDS_TANALYZE, IDS_STANALYZE, (LPARAM) &dlgAnalyzePage ) );
  503. THR( HrAddWizardPage( &pshead, IDD_CSACCOUNT, CCSAccountPage::S_DlgProc, IDS_TCSACCOUNT, IDS_STCSACCOUNT, (LPARAM) &dlgCSAccountPage ) );
  504. THR( HrAddWizardPage( &pshead, IDD_SUMMARY, CSummaryPage::S_DlgProc, IDS_TSUMMARY, IDS_STSUMMARY_ADD, (LPARAM) &dlgSummaryPage ) );
  505. THR( HrAddWizardPage( &pshead, IDD_COMMIT, CCommitPage::S_DlgProc, IDS_TCOMMIT_ADD, IDS_STCOMMIT, (LPARAM) &dlgCommitPage ) );
  506. THR( HrAddWizardPage( &pshead, IDD_COMPLETION, CCompletionPage::S_DlgProc, 0, 0, (LPARAM) &dlgCompletionPage ) );
  507. AssertMsg( pshead.nPages == ARRAYSIZE( rPages ), "Not enough or too many PROPSHEETPAGEs." );
  508. ipStatus = PropertySheet( &pshead );
  509. fSuccess = ipStatus != NULL;
  510. if ( pfDoneOut != NULL )
  511. {
  512. *pfDoneOut = fSuccess;
  513. }
  514. Cleanup:
  515. if ( plm != NULL )
  516. {
  517. THR( plm->StopLogging() );
  518. plm->Release();
  519. }
  520. HRETURN( hr );
  521. InvalidPointer:
  522. hr = THR( E_POINTER );
  523. goto Cleanup;
  524. } //*** CClusCfgWizard::AddClusterNodes()
  525. //////////////////////////////////////////////////////////////////////////
  526. //++
  527. //
  528. // STDMETHODIMP
  529. // CClusCfgWizard::get_ClusterName(
  530. // BSTR * pbstrNameOut
  531. // )
  532. //
  533. //--
  534. //////////////////////////////////////////////////////////////////////////
  535. STDMETHODIMP
  536. CClusCfgWizard::get_ClusterName(
  537. BSTR * pbstrNameOut
  538. )
  539. {
  540. HRESULT hr = S_OK;
  541. TraceFunc( "[IClusCfgWizard]" );
  542. if ( pbstrNameOut == NULL )
  543. goto InvalidPointer;
  544. if ( m_bstrClusterName == NULL )
  545. goto ErrorNotFound;
  546. *pbstrNameOut = TraceSysAllocString( m_bstrClusterName );
  547. if ( *pbstrNameOut == NULL )
  548. goto OutOfMemory;
  549. Cleanup:
  550. HRETURN( hr );
  551. OutOfMemory:
  552. hr = E_OUTOFMEMORY;
  553. goto Cleanup;
  554. InvalidPointer:
  555. hr = THR( E_POINTER );
  556. goto Cleanup;
  557. ErrorNotFound:
  558. hr = S_FALSE;
  559. *pbstrNameOut = NULL;
  560. goto Cleanup;
  561. } //*** CClusCfgWizard::get_ClusterName()
  562. //////////////////////////////////////////////////////////////////////////
  563. //++
  564. //
  565. // STDMETHODIMP
  566. // CClusCfgWizard::put_ClusterName(
  567. // BSTR bstrNameIn
  568. // )
  569. //
  570. //--
  571. //////////////////////////////////////////////////////////////////////////
  572. STDMETHODIMP
  573. CClusCfgWizard::put_ClusterName(
  574. BSTR bstrNameIn
  575. )
  576. {
  577. TraceFunc1( "[IClusCfgWizard] bstrNameIn = %'ls'", bstrNameIn == NULL ? L"<null>" : bstrNameIn );
  578. HRESULT hr = S_OK;
  579. BSTR bstrNewName;
  580. WCHAR * pszDomain = NULL;
  581. BSTR bstrDomain = NULL;
  582. DNS_STATUS dnsStatus;
  583. if ( bstrNameIn == NULL )
  584. goto InvalidArg;
  585. //
  586. // BUGBUG: 23-AUG-2000 GalenB
  587. //
  588. // This call succeeds when just a computer name is passed in. Is it supposed to fail
  589. // is the name is not a FQDN?
  590. //
  591. dnsStatus = TW32( DnsValidateName( bstrNameIn, DnsNameHostnameFull ) );
  592. if ( dnsStatus != ERROR_SUCCESS )
  593. {
  594. hr = HRESULT_FROM_WIN32( dnsStatus );
  595. goto Cleanup;
  596. }
  597. //
  598. // KB: 23-AUG-2000 GalenB
  599. //
  600. // If this passed in name is not a FQDN get this client's domain and append it.
  601. //
  602. pszDomain = wcschr( bstrNameIn, L'.' );
  603. if ( pszDomain == NULL )
  604. {
  605. hr = THR( HrGetComputerName( ComputerNamePhysicalDnsDomain, &bstrDomain ) );
  606. if ( FAILED( hr ) )
  607. goto Cleanup;
  608. bstrNewName = TraceSysAllocStringLen( NULL, wcslen( bstrNameIn ) + ( UINT ) wcslen( bstrDomain ) + 2 );
  609. if ( bstrNewName == NULL )
  610. {
  611. goto OutOfMemory;
  612. } // if:
  613. wcscpy( bstrNewName, bstrNameIn );
  614. wcscat( bstrNewName, L"." );
  615. wcscat( bstrNewName, bstrDomain );
  616. } // if: need to get a domain
  617. else
  618. {
  619. bstrNewName = TraceSysAllocString( bstrNameIn );
  620. if ( bstrNewName == NULL )
  621. goto OutOfMemory;
  622. } // else: passed in name is most likely a FQDN
  623. if ( m_bstrClusterName != NULL )
  624. {
  625. TraceSysFreeString( m_bstrClusterName );
  626. }
  627. m_bstrClusterName = bstrNewName;
  628. Cleanup:
  629. if ( bstrDomain != NULL )
  630. {
  631. TraceSysFreeString( bstrDomain );
  632. } // if:
  633. HRETURN( hr );
  634. InvalidArg:
  635. hr = THR( E_INVALIDARG );
  636. goto Cleanup;
  637. OutOfMemory:
  638. hr = E_OUTOFMEMORY;
  639. goto Cleanup;
  640. } //*** CClusCfgWizard::put_ClusterName()
  641. //////////////////////////////////////////////////////////////////////////
  642. //++
  643. //
  644. // STDMETHODIMP
  645. // CClusCfgWizard::get_ServiceAccountUserName(
  646. // BSTR * pbstrNameOut
  647. // )
  648. //
  649. //--
  650. //////////////////////////////////////////////////////////////////////////
  651. STDMETHODIMP
  652. CClusCfgWizard::get_ServiceAccountUserName(
  653. BSTR * pbstrNameOut
  654. )
  655. {
  656. TraceFunc( "[IClusCfgWizard]" );
  657. HRESULT hr = S_OK;
  658. if ( pbstrNameOut == NULL )
  659. goto InvalidPointer;
  660. if ( m_bstrAccountName == NULL )
  661. goto ErrorNotFound;
  662. *pbstrNameOut = TraceSysAllocString( m_bstrAccountName );
  663. if ( *pbstrNameOut == NULL )
  664. goto OutOfMemory;
  665. Cleanup:
  666. HRETURN( hr );
  667. InvalidPointer:
  668. hr = THR( E_POINTER );
  669. goto Cleanup;
  670. OutOfMemory:
  671. hr = E_OUTOFMEMORY;
  672. goto Cleanup;
  673. ErrorNotFound:
  674. hr = S_FALSE;
  675. *pbstrNameOut = NULL;
  676. goto Cleanup;
  677. } //*** CClusCfgWizard::get_ServiceAccountUserName()
  678. //////////////////////////////////////////////////////////////////////////
  679. //++
  680. //
  681. // STDMETHODIMP
  682. // CClusCfgWizard::put_ServiceAccountUserName(
  683. // BSTR bstrNameIn
  684. // )
  685. //
  686. //--
  687. //////////////////////////////////////////////////////////////////////////
  688. STDMETHODIMP
  689. CClusCfgWizard::put_ServiceAccountUserName(
  690. BSTR bstrNameIn
  691. )
  692. {
  693. TraceFunc1( "[IClusCfgWizard] bstrNameIn = '%ls'", bstrNameIn == NULL ? L"<null>" : bstrNameIn );
  694. HRESULT hr = S_OK;
  695. BSTR bstrNewName;
  696. if ( bstrNameIn == NULL )
  697. goto InvalidArg;
  698. bstrNewName = TraceSysAllocString( bstrNameIn );
  699. if ( bstrNewName == NULL )
  700. goto OutOfMemory;
  701. if ( m_bstrAccountName != NULL )
  702. {
  703. TraceSysFreeString( m_bstrAccountName );
  704. }
  705. m_bstrAccountName = bstrNewName;
  706. Cleanup:
  707. HRETURN( hr );
  708. InvalidArg:
  709. hr = THR( E_INVALIDARG );
  710. goto Cleanup;
  711. OutOfMemory:
  712. hr = E_OUTOFMEMORY;
  713. goto Cleanup;
  714. } //*** CClusCfgWizard::put_ServiceAccountUserName()
  715. //////////////////////////////////////////////////////////////////////////
  716. //++
  717. //
  718. // STDMETHODIMP
  719. // CClusCfgWizard::get_ServiceAccountPassword(
  720. // BSTR * pbstrPasswordOut
  721. // )
  722. //
  723. //--
  724. //////////////////////////////////////////////////////////////////////////
  725. STDMETHODIMP
  726. CClusCfgWizard::get_ServiceAccountPassword(
  727. BSTR * pbstrPasswordOut
  728. )
  729. {
  730. TraceFunc( "[IClusCfgWizard]" );
  731. HRESULT hr = S_OK;
  732. if ( pbstrPasswordOut == NULL )
  733. goto InvalidPointer;
  734. if ( m_bstrPassword == NULL )
  735. goto ErrorNotFound;
  736. *pbstrPasswordOut = SysAllocString( m_bstrPassword );
  737. if ( *pbstrPasswordOut == NULL )
  738. goto OutOfMemory;
  739. Cleanup:
  740. HRETURN( hr );
  741. InvalidPointer:
  742. hr = THR( E_POINTER );
  743. goto Cleanup;
  744. OutOfMemory:
  745. hr = E_OUTOFMEMORY;
  746. goto Cleanup;
  747. ErrorNotFound:
  748. hr = S_FALSE;
  749. *pbstrPasswordOut = NULL;
  750. goto Cleanup;
  751. } //*** CClusCfgWizard::get_ServiceAccountPassword()
  752. //////////////////////////////////////////////////////////////////////////
  753. //++
  754. //
  755. // STDMETHODIMP
  756. // CClusCfgWizard::put_ServiceAccountPassword(
  757. // BSTR bstrPasswordIn
  758. // )
  759. //
  760. //--
  761. //////////////////////////////////////////////////////////////////////////
  762. STDMETHODIMP
  763. CClusCfgWizard::put_ServiceAccountPassword(
  764. BSTR bstrPasswordIn
  765. )
  766. {
  767. TraceFunc( "[IClusCfgWizard]" );
  768. HRESULT hr = S_OK;
  769. BSTR bstrNewPassword;
  770. if ( bstrPasswordIn == NULL )
  771. goto InvalidArg;
  772. bstrNewPassword = TraceSysAllocString( bstrPasswordIn );
  773. if ( bstrNewPassword == NULL )
  774. goto OutOfMemory;
  775. if ( m_bstrPassword != NULL )
  776. {
  777. TraceSysFreeString( m_bstrPassword );
  778. }
  779. m_bstrPassword = bstrNewPassword;
  780. Cleanup:
  781. HRETURN( hr );
  782. InvalidArg:
  783. hr = THR( E_INVALIDARG );
  784. goto Cleanup;
  785. OutOfMemory:
  786. hr = E_OUTOFMEMORY;
  787. goto Cleanup;
  788. } //*** CClusCfgWizard::put_ServiceAccountPassword()
  789. //////////////////////////////////////////////////////////////////////////
  790. //++
  791. //
  792. // STDMETHODIMP
  793. // CClusCfgWizard::get_ServiceAccountDomainName(
  794. // BSTR * pbstrDomainOut
  795. // )
  796. //
  797. //--
  798. //////////////////////////////////////////////////////////////////////////
  799. STDMETHODIMP
  800. CClusCfgWizard::get_ServiceAccountDomainName(
  801. BSTR * pbstrDomainOut
  802. )
  803. {
  804. TraceFunc( "[IClusCfgWizard]" );
  805. HRESULT hr = S_OK;
  806. if ( pbstrDomainOut == NULL )
  807. goto InvalidPointer;
  808. if ( m_bstrDomain == NULL )
  809. goto ErrorNotFound;
  810. *pbstrDomainOut = TraceSysAllocString( m_bstrDomain );
  811. if ( *pbstrDomainOut == NULL )
  812. goto OutOfMemory;
  813. Cleanup:
  814. HRETURN( hr );
  815. InvalidPointer:
  816. hr = THR( E_POINTER );
  817. goto Cleanup;
  818. OutOfMemory:
  819. hr = E_OUTOFMEMORY;
  820. goto Cleanup;
  821. ErrorNotFound:
  822. hr = S_FALSE;
  823. *pbstrDomainOut = NULL;
  824. goto Cleanup;
  825. } //*** CClusCfgWizard::get_ServiceAccountDomainName()
  826. //////////////////////////////////////////////////////////////////////////
  827. //++
  828. //
  829. // STDMETHODIMP
  830. // CClusCfgWizard::put_ServiceAccountDomainName(
  831. // BSTR bstrDomainIn
  832. // )
  833. //
  834. //--
  835. //////////////////////////////////////////////////////////////////////////
  836. STDMETHODIMP
  837. CClusCfgWizard::put_ServiceAccountDomainName(
  838. BSTR bstrDomainIn
  839. )
  840. {
  841. TraceFunc1( "[IClusCfgWizard] bstrDomainIn = '%ls'", bstrDomainIn == NULL ? L"<null>" : bstrDomainIn );
  842. HRESULT hr = S_OK;
  843. BSTR bstrNewDomain;
  844. if ( bstrDomainIn == NULL )
  845. goto InvalidArg;
  846. bstrNewDomain = TraceSysAllocString( bstrDomainIn );
  847. if ( bstrNewDomain == NULL )
  848. goto OutOfMemory;
  849. if ( m_bstrDomain != NULL )
  850. {
  851. TraceSysFreeString( m_bstrDomain );
  852. }
  853. m_bstrDomain = bstrNewDomain;
  854. Cleanup:
  855. HRETURN( hr );
  856. InvalidArg:
  857. hr = THR( E_INVALIDARG );
  858. goto Cleanup;
  859. OutOfMemory:
  860. hr = THR( E_OUTOFMEMORY );
  861. goto Cleanup;
  862. } //*** CClusCfgWizard::put_ServiceAccountDomainName()
  863. //////////////////////////////////////////////////////////////////////////
  864. //++
  865. //
  866. // STDMETHODIMP
  867. // CClusCfgWizard::get_ClusterIPAddress(
  868. // BSTR * pbstrIPAddressOut
  869. // )
  870. //
  871. //--
  872. //////////////////////////////////////////////////////////////////////////
  873. STDMETHODIMP
  874. CClusCfgWizard::get_ClusterIPAddress(
  875. BSTR * pbstrIPAddressOut
  876. )
  877. {
  878. TraceFunc( "[IClusCfgWizard]" );
  879. HRESULT hr = S_OK;
  880. DWORD dwStatus;
  881. LPWSTR pwszIPAddress = NULL;
  882. if ( pbstrIPAddressOut == NULL )
  883. goto InvalidPointer;
  884. if ( m_ulIPAddress == 0 )
  885. goto ErrorNotFound;
  886. dwStatus = ClRtlTcpipAddressToString( m_ulIPAddress, &pwszIPAddress );
  887. if ( dwStatus != ERROR_SUCCESS )
  888. goto Win32Error;
  889. *pbstrIPAddressOut = TraceSysAllocString( pwszIPAddress );
  890. if ( *pbstrIPAddressOut == NULL )
  891. goto OutOfMemory;
  892. Cleanup:
  893. if ( pwszIPAddress != NULL )
  894. {
  895. LocalFree( pwszIPAddress );
  896. }
  897. HRETURN( hr );
  898. InvalidPointer:
  899. hr = THR( E_POINTER );
  900. goto Cleanup;
  901. OutOfMemory:
  902. hr = E_OUTOFMEMORY;
  903. goto Cleanup;
  904. ErrorNotFound:
  905. hr = S_FALSE;
  906. *pbstrIPAddressOut = NULL;
  907. goto Cleanup;
  908. Win32Error:
  909. hr = HRESULT_FROM_WIN32( hr );
  910. goto Cleanup;
  911. } //*** CClusCfgWizard::get_ClusterIPAddress()
  912. //////////////////////////////////////////////////////////////////////////
  913. //++
  914. //
  915. // STDMETHODIMP
  916. // CClusCfgWizard::put_ClusterIPAddress(
  917. // BSTR bstrIPAddressIn
  918. // )
  919. //
  920. //--
  921. //////////////////////////////////////////////////////////////////////////
  922. STDMETHODIMP
  923. CClusCfgWizard::put_ClusterIPAddress(
  924. BSTR bstrIPAddressIn
  925. )
  926. {
  927. TraceFunc1( "[IClusCfgWizard] bstrIPAddressIn = '%ls'", bstrIPAddressIn == NULL ? L"<null>" : bstrIPAddressIn );
  928. HRESULT hr = S_OK;
  929. DWORD dwStatus;
  930. if ( bstrIPAddressIn == NULL )
  931. goto InvalidArg;
  932. dwStatus = ClRtlTcpipStringToAddress( bstrIPAddressIn, &m_ulIPAddress );
  933. if ( dwStatus != ERROR_SUCCESS )
  934. goto Win32Error;
  935. Cleanup:
  936. HRETURN( hr );
  937. InvalidArg:
  938. hr = THR( E_INVALIDARG );
  939. goto Cleanup;
  940. Win32Error:
  941. hr = HRESULT_FROM_WIN32( dwStatus );
  942. goto Cleanup;
  943. } //*** CClusCfgWizard::put_ClusterIPAddress()
  944. //////////////////////////////////////////////////////////////////////////
  945. //++
  946. //
  947. // STDMETHODIMP
  948. // CClusCfgWizard::get_ClusterIPSubnet(
  949. // BSTR * pbstrIPSubnetOut
  950. // )
  951. //
  952. //--
  953. //////////////////////////////////////////////////////////////////////////
  954. STDMETHODIMP
  955. CClusCfgWizard::get_ClusterIPSubnet(
  956. BSTR * pbstrIPSubnetOut
  957. )
  958. {
  959. TraceFunc( "[IClusCfgWizard]" );
  960. HRESULT hr = S_OK;
  961. DWORD dwStatus;
  962. LPWSTR pwszIPSubnet = NULL;
  963. if ( pbstrIPSubnetOut == NULL )
  964. goto InvalidPointer;
  965. if ( m_ulIPSubnet == 0 )
  966. goto ErrorNotFound;
  967. dwStatus = ClRtlTcpipAddressToString( m_ulIPSubnet, &pwszIPSubnet );
  968. if ( dwStatus != ERROR_SUCCESS )
  969. goto Win32Error;
  970. *pbstrIPSubnetOut = TraceSysAllocString( pwszIPSubnet );
  971. if ( *pbstrIPSubnetOut == NULL )
  972. goto OutOfMemory;
  973. Cleanup:
  974. if ( pwszIPSubnet != NULL )
  975. {
  976. LocalFree( pwszIPSubnet );
  977. }
  978. HRETURN( hr );
  979. InvalidPointer:
  980. hr = THR( E_POINTER );
  981. goto Cleanup;
  982. OutOfMemory:
  983. hr = E_OUTOFMEMORY;
  984. goto Cleanup;
  985. ErrorNotFound:
  986. hr = S_FALSE;
  987. *pbstrIPSubnetOut = NULL;
  988. goto Cleanup;
  989. Win32Error:
  990. hr = HRESULT_FROM_WIN32( hr );
  991. goto Cleanup;
  992. } //*** CClusCfgWizard::get_ClusterIPSubnet()
  993. //////////////////////////////////////////////////////////////////////////
  994. //++
  995. //
  996. // STDMETHODIMP
  997. // CClusCfgWizard::put_ClusterIPSubnet(
  998. // BSTR bstrSubnetMaskIn
  999. // )
  1000. //
  1001. //--
  1002. //////////////////////////////////////////////////////////////////////////
  1003. STDMETHODIMP
  1004. CClusCfgWizard::put_ClusterIPSubnet(
  1005. BSTR bstrIPSubnetIn
  1006. )
  1007. {
  1008. TraceFunc1( "[IClusCfgWizard] bstrIPSubnetIn = '%ls'", bstrIPSubnetIn );
  1009. HRESULT hr = S_OK;
  1010. DWORD dwStatus;
  1011. if ( bstrIPSubnetIn == NULL )
  1012. goto InvalidArg;
  1013. dwStatus = ClRtlTcpipStringToAddress( bstrIPSubnetIn, &m_ulIPSubnet );
  1014. if ( dwStatus != ERROR_SUCCESS )
  1015. goto Win32Error;
  1016. Cleanup:
  1017. HRETURN( hr );
  1018. InvalidArg:
  1019. hr = THR( E_INVALIDARG );
  1020. goto Cleanup;
  1021. Win32Error:
  1022. hr = HRESULT_FROM_WIN32( dwStatus );
  1023. goto Cleanup;
  1024. } //*** CClusCfgWizard::put_ClusterIPSubnet()
  1025. //////////////////////////////////////////////////////////////////////////
  1026. //++
  1027. //
  1028. // STDMETHODIMP
  1029. // CClusCfgWizard::get_ClusterIPAddressNetwork(
  1030. // BSTR * pbstrNetworkNameOut
  1031. // )
  1032. //
  1033. //--
  1034. //////////////////////////////////////////////////////////////////////////
  1035. STDMETHODIMP
  1036. CClusCfgWizard::get_ClusterIPAddressNetwork(
  1037. BSTR * pbstrNetworkNameOut
  1038. )
  1039. {
  1040. TraceFunc( "[IClusCfgWizard]" );
  1041. HRESULT hr = S_OK;
  1042. if ( pbstrNetworkNameOut == NULL )
  1043. goto InvalidPointer;
  1044. if ( m_bstrNetworkName == NULL )
  1045. goto ErrorNotFound;
  1046. *pbstrNetworkNameOut = TraceSysAllocString( m_bstrNetworkName );
  1047. if ( *pbstrNetworkNameOut == NULL )
  1048. goto OutOfMemory;
  1049. Cleanup:
  1050. HRETURN( hr );
  1051. InvalidPointer:
  1052. hr = THR( E_POINTER );
  1053. goto Cleanup;
  1054. OutOfMemory:
  1055. hr = E_OUTOFMEMORY;
  1056. goto Cleanup;
  1057. ErrorNotFound:
  1058. hr = S_FALSE;
  1059. *pbstrNetworkNameOut = NULL;
  1060. goto Cleanup;
  1061. } //*** CClusCfgWizard::get_ClusterIPAddressNetwork()
  1062. //////////////////////////////////////////////////////////////////////////
  1063. //++
  1064. //
  1065. // STDMETHODIMP
  1066. // CClusCfgWizard::put_ClusterIPAddressNetwork(
  1067. // BSTR bstrNetworkNameIn
  1068. // )
  1069. //
  1070. //--
  1071. //////////////////////////////////////////////////////////////////////////
  1072. STDMETHODIMP
  1073. CClusCfgWizard::put_ClusterIPAddressNetwork(
  1074. BSTR bstrNetworkNameIn
  1075. )
  1076. {
  1077. TraceFunc1( "[IClusCfgWizard] bstrNetworkNameIn = '%ls'", bstrNetworkNameIn == NULL ? L"<null>" : bstrNetworkNameIn );
  1078. HRESULT hr = S_OK;
  1079. BSTR bstrNewNetworkName;
  1080. if ( bstrNetworkNameIn == NULL )
  1081. goto InvalidArg;
  1082. bstrNewNetworkName = TraceSysAllocString( bstrNetworkNameIn );
  1083. if ( bstrNewNetworkName == NULL )
  1084. goto OutOfMemory;
  1085. if ( m_bstrNetworkName != NULL )
  1086. {
  1087. TraceSysFreeString( m_bstrNetworkName );
  1088. }
  1089. m_bstrNetworkName = bstrNewNetworkName;
  1090. Cleanup:
  1091. HRETURN( hr );
  1092. InvalidArg:
  1093. hr = THR( E_INVALIDARG );
  1094. goto Cleanup;
  1095. OutOfMemory:
  1096. hr = THR( E_OUTOFMEMORY );
  1097. goto Cleanup;
  1098. } //*** CClusCfgWizard::put_ClusterIPAddressNetwork()
  1099. //////////////////////////////////////////////////////////////////////////////
  1100. //
  1101. // STDMETHODIMP
  1102. // CClusCfgWizard::AddComputer(
  1103. // LPCWSTR bstrNameIn
  1104. // )
  1105. //
  1106. //////////////////////////////////////////////////////////////////////////////
  1107. STDMETHODIMP
  1108. CClusCfgWizard::AddComputer(
  1109. LPCWSTR pcszNameIn
  1110. )
  1111. {
  1112. TraceFunc1( "[IClusCfgWizard] pcszNameIn = '%ls'", pcszNameIn == NULL ? L"<null>" : pcszNameIn );
  1113. HRESULT hr = S_OK;
  1114. BSTR * rgbstrNewArray;
  1115. WCHAR wszNameToAdd[ DNS_MAX_NAME_BUFFER_LENGTH ];
  1116. ULONG cNewArraySize;
  1117. ULONG idx;
  1118. if ( ( pcszNameIn == NULL ) || ( wcslen( pcszNameIn ) > DNS_MAX_NAME_BUFFER_LENGTH-1 ) )
  1119. goto InvalidArg;
  1120. //
  1121. // If pcszNameIn is a FQDN, truncate. Otherwise, simply copy it.
  1122. //
  1123. if ( wcschr( pcszNameIn, L'.' ) == NULL )
  1124. {
  1125. wcscpy( wszNameToAdd, pcszNameIn );
  1126. }
  1127. else
  1128. {
  1129. size_t cHostNameSize;
  1130. cHostNameSize = wcscspn( pcszNameIn, L"." );
  1131. wcsncpy( wszNameToAdd, pcszNameIn, cHostNameSize );
  1132. wszNameToAdd[ cHostNameSize ] = L'\0';
  1133. }
  1134. //
  1135. // Check to see if it already exists.
  1136. //
  1137. for ( idx = 0; idx < m_cComputers; idx++ )
  1138. {
  1139. if ( wcscmp( m_rgbstrComputers[ idx ], wszNameToAdd ) == 0 )
  1140. goto AlreadyAdded;
  1141. }
  1142. //
  1143. // Add a new entry to the list.
  1144. //
  1145. if ( m_cComputers == m_cArraySize )
  1146. {
  1147. cNewArraySize = m_cArraySize + 10;
  1148. if ( m_rgbstrComputers == NULL )
  1149. {
  1150. rgbstrNewArray = (BSTR *) TraceAlloc( 0, cNewArraySize * sizeof( BSTR ) );
  1151. }
  1152. else
  1153. {
  1154. rgbstrNewArray = (BSTR *) TraceReAlloc( m_rgbstrComputers, cNewArraySize * sizeof( BSTR ), 0 );
  1155. }
  1156. if ( rgbstrNewArray == NULL )
  1157. goto OutOfMemory;
  1158. m_cArraySize = cNewArraySize;
  1159. m_rgbstrComputers = rgbstrNewArray;
  1160. }
  1161. m_rgbstrComputers[ m_cComputers ] = TraceSysAllocString( wszNameToAdd );
  1162. if ( m_rgbstrComputers[ m_cComputers ] == NULL )
  1163. goto OutOfMemory;
  1164. m_cComputers ++;
  1165. Cleanup:
  1166. HRETURN( hr );
  1167. InvalidArg:
  1168. hr = THR( E_INVALIDARG );
  1169. goto Cleanup;
  1170. AlreadyAdded:
  1171. hr = S_OK;
  1172. goto Cleanup;
  1173. OutOfMemory:
  1174. hr = E_OUTOFMEMORY;
  1175. goto Cleanup;
  1176. } // AddComputer( )
  1177. //////////////////////////////////////////////////////////////////////////////
  1178. //
  1179. // STDMETHODIMP
  1180. // CClusCfgWizard::RemoveComputer(
  1181. // LPCWSTR pcszNameIn
  1182. // )
  1183. //
  1184. //////////////////////////////////////////////////////////////////////////////
  1185. STDMETHODIMP
  1186. CClusCfgWizard::RemoveComputer(
  1187. LPCWSTR pcszNameIn
  1188. )
  1189. {
  1190. TraceFunc1( "[IClusCfgWizard] pcszNameIn = '%ls'", pcszNameIn == NULL ? L"<null>" : pcszNameIn );
  1191. HRESULT hr = S_FALSE;
  1192. ULONG idx;
  1193. if ( pcszNameIn == NULL )
  1194. goto InvalidArg;
  1195. for( idx = 0; idx < m_cComputers; idx ++ )
  1196. {
  1197. if ( wcscmp( m_rgbstrComputers[ idx ], pcszNameIn ) == 0 )
  1198. {
  1199. //
  1200. // Match. Remove the entry by shifting the list.
  1201. //
  1202. m_cComputers --;
  1203. MoveMemory( &m_rgbstrComputers[ idx ], &m_rgbstrComputers[ idx + 1], m_cComputers - idx );
  1204. hr = S_OK;
  1205. break;
  1206. }
  1207. }
  1208. Cleanup:
  1209. HRETURN( hr );
  1210. InvalidArg:
  1211. hr = THR( E_INVALIDARG );
  1212. goto Cleanup;
  1213. } // RemoveComputer( )
  1214. //////////////////////////////////////////////////////////////////////////////
  1215. //
  1216. // STDMETHODIMP
  1217. // CClusCfgWizard::ClearComputerList( void )
  1218. //
  1219. //////////////////////////////////////////////////////////////////////////////
  1220. STDMETHODIMP
  1221. CClusCfgWizard::ClearComputerList( void )
  1222. {
  1223. TraceFunc( "[IClusCfgWizard]" );
  1224. HRESULT hr = S_OK;
  1225. ULONG idx;
  1226. for ( idx = 0; idx < m_cComputers; idx ++ )
  1227. {
  1228. TraceSysFreeString( m_rgbstrComputers[ idx ] );
  1229. }
  1230. m_cComputers = 0;
  1231. HRETURN( hr );
  1232. } // ClearComputerList( )
  1233. //****************************************************************************
  1234. //
  1235. // IDispatch
  1236. //
  1237. //****************************************************************************
  1238. //////////////////////////////////////////////////////////////////////////////
  1239. //++
  1240. //
  1241. // STDMETHODIMP
  1242. // [IDispatch] CClusCfgWizard::GetTypeInfoCount(
  1243. // UINT * pctinfo
  1244. // )
  1245. //
  1246. // Description:
  1247. //
  1248. // Arguments:
  1249. // pctinfoOut
  1250. //
  1251. // Return Values:
  1252. // NOERROR
  1253. //
  1254. //--
  1255. //////////////////////////////////////////////////////////////////////////////
  1256. STDMETHODIMP
  1257. CClusCfgWizard::GetTypeInfoCount(
  1258. UINT * pctinfoOut
  1259. )
  1260. {
  1261. TraceFunc( "[IDispatch]" );
  1262. *pctinfoOut = 1;
  1263. HRETURN( NOERROR );
  1264. } //*** CClusCfgWizard::GetTypeInfoCount()
  1265. //////////////////////////////////////////////////////////////////////////////
  1266. //++
  1267. //
  1268. // STDMETHODIMP
  1269. // [IDispatch] CClusCfgWizard::GetTypeInfo(
  1270. // UINT itinfoIn,
  1271. // LCID lcidIn,
  1272. // ITypeInfo ** pptinfoOut
  1273. // )
  1274. //
  1275. // Description:
  1276. //
  1277. // Arguments:
  1278. // itinfoIn
  1279. // lcidIn
  1280. // pptinfoOut
  1281. //
  1282. // Return Values:
  1283. // NOERROR
  1284. // DISP_E_BADINDEX
  1285. //
  1286. //--
  1287. //////////////////////////////////////////////////////////////////////////////
  1288. STDMETHODIMP CClusCfgWizard::GetTypeInfo(
  1289. UINT itinfoIn,
  1290. LCID lcidIn,
  1291. ITypeInfo ** pptinfoOut
  1292. )
  1293. {
  1294. TraceFunc( "[IDispatch]" );
  1295. HRESULT hr = NOERROR;
  1296. *pptinfoOut = NULL;
  1297. if ( itinfoIn != 0 )
  1298. {
  1299. hr = DISP_E_BADINDEX;
  1300. }
  1301. else
  1302. {
  1303. m_ptinfo->AddRef();
  1304. *pptinfoOut = m_ptinfo;
  1305. }
  1306. HRETURN( hr );
  1307. } //*** CClusCfgWizard::GetTypeInfo()
  1308. //////////////////////////////////////////////////////////////////////////////
  1309. //++
  1310. //
  1311. // STDMETHODIMP
  1312. // [IDispatch] CClusCfgWizard::GetIDsOfNames(
  1313. // REFIID riid,
  1314. // OLECHAR ** rgszNames,
  1315. // UINT cNames,
  1316. // LCID lcid,
  1317. // DISPID * rgdispid
  1318. // )
  1319. //
  1320. // Description:
  1321. //
  1322. // Arguments:
  1323. // riid
  1324. // rgszNames
  1325. // cNames
  1326. // lcid
  1327. // rgdispid
  1328. //
  1329. // Return Values:
  1330. // HRESULT from DispGetIDsOfNames().
  1331. //
  1332. //--
  1333. //////////////////////////////////////////////////////////////////////////////
  1334. STDMETHODIMP
  1335. CClusCfgWizard::GetIDsOfNames(
  1336. REFIID riid,
  1337. OLECHAR ** rgszNames,
  1338. UINT cNames,
  1339. LCID lcid,
  1340. DISPID * rgdispid
  1341. )
  1342. {
  1343. TraceFunc( "[IDispatch]" );
  1344. HRESULT hr;
  1345. hr = DispGetIDsOfNames( m_ptinfo, rgszNames, cNames, rgdispid );
  1346. HRETURN( hr );
  1347. } //*** CClusCfgWizard::GetIDsOfNames()
  1348. //////////////////////////////////////////////////////////////////////////////
  1349. //++
  1350. //
  1351. // STDMETHODIMP
  1352. // [IDispatch] CClusCfgWizard::Invoke(
  1353. // DISPID dispidMember,
  1354. // REFIID riid,
  1355. // LCID lcid,
  1356. // WORD wFlags,
  1357. // DISPPARAMS * pdispparams,
  1358. // VARIANT * pvarResult,
  1359. // EXCEPINFO * pexcepinfo,
  1360. // UINT * puArgErr
  1361. // )
  1362. //
  1363. // Description:
  1364. //
  1365. // Arguments:
  1366. // dispidMember
  1367. // riid
  1368. // lcid
  1369. // pdispparams
  1370. // pvarResult
  1371. // pexceptinfo
  1372. // puArgErr
  1373. //
  1374. // Return Values:
  1375. // HRESULT from DispInvoke().
  1376. //
  1377. //--
  1378. //////////////////////////////////////////////////////////////////////////////
  1379. STDMETHODIMP
  1380. CClusCfgWizard::Invoke(
  1381. DISPID dispidMember,
  1382. REFIID riid,
  1383. LCID lcid,
  1384. WORD wFlags,
  1385. DISPPARAMS * pdispparams,
  1386. VARIANT * pvarResult,
  1387. EXCEPINFO * pexcepinfo,
  1388. UINT * puArgErr
  1389. )
  1390. {
  1391. TraceFunc( "[IDispatch]" );
  1392. HRESULT hr;
  1393. hr = DispInvoke(
  1394. this,
  1395. m_ptinfo,
  1396. dispidMember,
  1397. wFlags,
  1398. pdispparams,
  1399. pvarResult,
  1400. pexcepinfo,
  1401. puArgErr
  1402. );
  1403. HRETURN( hr );
  1404. } //*** CClusCfgWizard::Invoke()
  1405. //****************************************************************************
  1406. //
  1407. // Private
  1408. //
  1409. //****************************************************************************
  1410. //////////////////////////////////////////////////////////////////////////////
  1411. //
  1412. // HRESULT
  1413. // HrAddWizardPage(
  1414. // LPPROPSHEETHEADER ppshInout,
  1415. // UINT idTemplateIn,
  1416. // DLGPROC pfnDlgProcIn,
  1417. // UINT idTitleIn,
  1418. // UINT idSubtitleIn,
  1419. // LPARAM lParam
  1420. // )
  1421. //
  1422. // Description:
  1423. // Fills in the PROPSHEETPAGE structure, create the page and adds it to
  1424. // the wizard's PROPSHEETHEADER.
  1425. //
  1426. // Parameters:
  1427. // ppshInout
  1428. // LPPROPSHEETHEADER structure to add page to.
  1429. //
  1430. // idTemplateIn
  1431. // The dialog template ID of the page.
  1432. //
  1433. // pfnDlgProcIn
  1434. // The dialog proc for the page.
  1435. //
  1436. // idCaptionIn
  1437. // The page's caption.
  1438. //
  1439. // idTitleIn
  1440. // The page's title.
  1441. //
  1442. // idSubtitleIn
  1443. // The page's sub-title.
  1444. //
  1445. // lParam
  1446. // The lParam to be put into the PROPSHEETPAGE stucture's lParam.
  1447. //
  1448. // Return Values:
  1449. // S_OK
  1450. // The call succeeded.
  1451. //
  1452. //////////////////////////////////////////////////////////////////////////////
  1453. HRESULT
  1454. CClusCfgWizard::HrAddWizardPage(
  1455. LPPROPSHEETHEADER ppshInout,
  1456. UINT idTemplateIn,
  1457. DLGPROC pfnDlgProcIn,
  1458. UINT idTitleIn,
  1459. UINT idSubtitleIn,
  1460. LPARAM lParam
  1461. )
  1462. {
  1463. TraceFunc( "" );
  1464. PROPSHEETPAGE psp;
  1465. TCHAR szTitle[ 256 ];
  1466. TCHAR szSubTitle[ 256 ];
  1467. ZeroMemory( &psp, sizeof(psp) );
  1468. psp.dwSize = sizeof(psp);
  1469. psp.dwFlags = PSP_USETITLE;
  1470. psp.pszTitle = ppshInout->pszCaption;
  1471. psp.hInstance = ppshInout->hInstance;
  1472. psp.pszTemplate = MAKEINTRESOURCE( idTemplateIn );
  1473. psp.pfnDlgProc = pfnDlgProcIn;
  1474. psp.lParam = lParam;
  1475. if ( ( idTemplateIn == IDD_WELCOME_CREATE )
  1476. || ( idTemplateIn == IDD_WELCOME_ADD )
  1477. || ( idTemplateIn == IDD_COMPLETION )
  1478. )
  1479. {
  1480. psp.dwFlags |= PSP_HIDEHEADER;
  1481. }
  1482. else
  1483. {
  1484. if ( idTitleIn != 0 )
  1485. {
  1486. DWORD dw;
  1487. dw = LoadString( g_hInstance, idTitleIn, szTitle, ARRAYSIZE(szTitle) );
  1488. Assert( dw );
  1489. psp.pszHeaderTitle = szTitle;
  1490. psp.dwFlags |= PSP_USEHEADERTITLE;
  1491. }
  1492. else
  1493. {
  1494. psp.pszHeaderTitle = NULL;
  1495. }
  1496. if ( idSubtitleIn != 0 )
  1497. {
  1498. DWORD dw;
  1499. dw = LoadString( g_hInstance, idSubtitleIn, szSubTitle, ARRAYSIZE(szSubTitle) );
  1500. Assert( dw );
  1501. psp.pszHeaderSubTitle = szSubTitle;
  1502. psp.dwFlags |= PSP_USEHEADERSUBTITLE;
  1503. }
  1504. else
  1505. {
  1506. psp.pszHeaderSubTitle = NULL;
  1507. }
  1508. }
  1509. ppshInout->phpage[ ppshInout->nPages ] = CreatePropertySheetPage( &psp );
  1510. Assert( ppshInout->phpage[ ppshInout->nPages ] != NULL );
  1511. if ( ppshInout->phpage[ ppshInout->nPages ] != NULL )
  1512. {
  1513. ppshInout->nPages++;
  1514. }
  1515. HRETURN( S_OK );
  1516. } // HrAddWizardPage( )