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.

1669 lines
42 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. // Compdata.cpp : Implementation of CCompdata
  3. #include "stdafx.h"
  4. #include <ntverp.h>
  5. #include "tscc.h"
  6. #include "dataobj.h"
  7. #include "Compdata.h"
  8. #include "comp.h"
  9. #include <regapi.h>
  10. #include "cfgbkend_i.c"
  11. void ErrMessage( HWND hwndOwner , INT_PTR iResourceID );
  12. extern void xxxErrMessage( HWND hwnd , INT_PTR nResMessageId , INT_PTR nResTitleId , UINT nFlags );
  13. extern void TscAccessDeniedMsg( HWND hwnd );
  14. extern void TscGeneralErrMsg( HWND hwnd );
  15. void InitWarningThread( PVOID pvParam );
  16. extern "C" BOOL
  17. IsWhistlerAdvanceServer();
  18. BOOL g_bAppSrvMode = FALSE;
  19. #ifdef DBG
  20. bool g_fDebug = false;
  21. #endif
  22. //extern "C" BOOL RegisterCheckListWndClass( void );
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CCompdata
  25. //----------------------------------------------------------------------------------------------------------
  26. CCompdata::CCompdata( )
  27. {
  28. m_pConsole = NULL;
  29. m_pConsoleNameSpace = NULL;
  30. m_pCfgcomp = NULL;
  31. m_pMainRoot[ 0 ] = NULL;
  32. m_pMainRoot[ 1 ] = NULL;
  33. }
  34. //----------------------------------------------------------------------------------------------------------
  35. // NDMGR is asking for us to return a view of our doc ( MFC talk )
  36. //----------------------------------------------------------------------------------------------------------
  37. STDMETHODIMP CCompdata::CreateComponent( LPCOMPONENT * ppComponent)
  38. {
  39. *ppComponent = ( LPCOMPONENT )new CComp( this );
  40. if( *ppComponent == NULL )
  41. {
  42. return E_OUTOFMEMORY;
  43. }
  44. return S_OK;
  45. }
  46. //----------------------------------------------------------------------------------------------------------
  47. // Obtain interfaces used by for the scope pane
  48. //----------------------------------------------------------------------------------------------------------
  49. STDMETHODIMP CCompdata::Initialize( LPUNKNOWN pUnk )
  50. {
  51. HRESULT hr;
  52. #ifdef DBG
  53. HKEY hKey;
  54. LONG lStatus;
  55. // To control debug spewage add/remove this regkey
  56. lStatus = RegOpenKeyEx( HKEY_LOCAL_MACHINE ,
  57. L"Software\\Microsoft\\TSCC\\Debug",
  58. 0,
  59. KEY_READ,
  60. &hKey );
  61. if( lStatus == ERROR_SUCCESS )
  62. {
  63. g_fDebug = true;
  64. RegCloseKey( hKey );
  65. }
  66. #endif
  67. hr = pUnk->QueryInterface( IID_IConsole , ( LPVOID *)&m_pConsole );
  68. if( FAILED( hr ) )
  69. {
  70. return hr;
  71. }
  72. hr = pUnk->QueryInterface( IID_IConsoleNameSpace , ( LPVOID * )&m_pConsoleNameSpace );
  73. if( FAILED( hr ) )
  74. {
  75. return hr;
  76. }
  77. hr = CoCreateInstance( CLSID_CfgComp , NULL , CLSCTX_INPROC_SERVER , IID_ICfgComp , ( LPVOID *)&m_pCfgcomp );
  78. if( FAILED( hr ) )
  79. {
  80. return hr;
  81. }
  82. hr = m_pCfgcomp->Initialize( );
  83. if( FAILED( hr ) )
  84. {
  85. return hr;
  86. }
  87. // RegisterCheckListWndClass( );
  88. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_MAINFOLDERNAME , m_tchMainFolderName , SIZE_OF_BUFFER( m_tchMainFolderName ) ) );
  89. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_SETTINGSFOLDER , m_tchSettingsFolderName , SIZE_OF_BUFFER( m_tchSettingsFolderName ) ) );
  90. hr = BuildSettingsNodes( );
  91. if( FAILED( hr ) )
  92. {
  93. return hr;
  94. }
  95. hr = BuildResultNodes( );
  96. return hr;
  97. }
  98. //----------------------------------------------------------------------------------------------------------
  99. // Dispatch to notification handlers
  100. //----------------------------------------------------------------------------------------------------------
  101. STDMETHODIMP CCompdata::Notify( LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param)
  102. {
  103. HRESULT hr = NOERROR;
  104. switch( event )
  105. {
  106. case MMCN_RENAME:
  107. ODS( L"IComponentdata -- MMCN_RENAME\n");
  108. break;
  109. case MMCN_EXPAND:
  110. ODS( L"IComponentdata -- MMCN_EXPAND\n" );
  111. ExpandScopeTree( lpDataObject , ( BOOL ) arg , ( HSCOPEITEM )param );
  112. break;
  113. case MMCN_DELETE:
  114. ODS( L"IComponentdata -- MMCN_DELETE\n" );
  115. break;
  116. case MMCN_PROPERTY_CHANGE:
  117. ODS( L"IComponentdata -- MMCN_PROPERTY_CHANGE\n" );
  118. break;
  119. default:
  120. ODS( L"CCompdata::Notify - - event not defined!\n" );
  121. hr = E_NOTIMPL;
  122. }
  123. return hr;
  124. }
  125. //----------------------------------------------------------------------------------------------------------
  126. // Prepareing for parent entry
  127. BOOL CCompdata::ExpandScopeTree( LPDATAOBJECT pRoot , BOOL bExpand , HSCOPEITEM hConsole )
  128. {
  129. SCOPEDATAITEM sdi;
  130. if( !bExpand )
  131. {
  132. return FALSE;
  133. }
  134. CBaseNode *pNode = dynamic_cast< CBaseNode *>( pRoot );
  135. if( pNode == NULL )
  136. {
  137. return FALSE;
  138. }
  139. if( pNode->GetNodeType( ) != 0 ) // ROOT_NODE add subscope items
  140. {
  141. return FALSE;
  142. }
  143. // make sure we're not re-adding
  144. for( int i = 0 ; i < 2 ; i++ )
  145. {
  146. if( m_pMainRoot[ i ] != NULL )
  147. {
  148. return TRUE;
  149. }
  150. }
  151. for( i = 0 ; i < 2 ; i++ )
  152. {
  153. m_pMainRoot[ i ] = ( CBaseNode * )new CBaseNode;
  154. if( m_pMainRoot[ i ] == NULL )
  155. {
  156. ODS( L"TSCC: Scope node failed allocation\n" );
  157. return FALSE;
  158. }
  159. m_pMainRoot[ i ]->SetNodeType( i + MAIN_NODE );
  160. //m_pMainRoot[ i ]->AddRef( );
  161. ZeroMemory( &sdi , sizeof( SCOPEDATAITEM ) );
  162. sdi.mask = SDI_STR | SDI_PARAM | SDI_PARENT;
  163. sdi.displayname = MMC_CALLBACK;
  164. sdi.relativeID = hConsole;
  165. sdi.lParam = (LPARAM)m_pMainRoot[ i ];
  166. if( FAILED( m_pConsoleNameSpace->InsertItem( &sdi ) ) )
  167. {
  168. //sdi.ID;
  169. return FALSE;
  170. }
  171. }
  172. return TRUE;
  173. }
  174. //----------------------------------------------------------------------------------------------------------
  175. STDMETHODIMP CCompdata::CompareObjects( LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB)
  176. {
  177. if( lpDataObjectA == lpDataObjectB )
  178. {
  179. return S_OK;
  180. }
  181. return E_FAIL;
  182. }
  183. //----------------------------------------------------------------------------------------------------------
  184. // Not yet finished
  185. //----------------------------------------------------------------------------------------------------------
  186. STDMETHODIMP CCompdata::GetDisplayInfo( LPSCOPEDATAITEM pItem)
  187. {
  188. CBaseNode *pNode = ( CBaseNode * )pItem->lParam;
  189. if( pItem->mask & SDI_STR )
  190. {
  191. if( pNode->GetNodeType( ) == MAIN_NODE )
  192. {
  193. //pItem->displayname = ( LPOLESTR )L"Connections";
  194. pItem->displayname = ( LPOLESTR )m_tchMainFolderName;
  195. }
  196. else if( pNode->GetNodeType( ) == SETTINGS_NODE )
  197. {
  198. // pItem->displayname = ( LPOLESTR )L"Server Settings";
  199. pItem->displayname = ( LPOLESTR )m_tchSettingsFolderName;
  200. }
  201. }
  202. return S_OK;
  203. }
  204. //----------------------------------------------------------------------------------------------------------
  205. STDMETHODIMP CCompdata::QueryDataObject( MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT * ppDataObject)
  206. {
  207. *ppDataObject = NULL;
  208. switch( type )
  209. {
  210. case CCT_SCOPE:
  211. case CCT_SNAPIN_MANAGER:
  212. if( cookie == 0 )
  213. {
  214. *ppDataObject = ( LPDATAOBJECT )new CBaseNode( );
  215. }
  216. else
  217. {
  218. *ppDataObject = ( LPDATAOBJECT )cookie;
  219. // this is the only scopenode keep this one alive
  220. ( ( LPDATAOBJECT )*ppDataObject)->AddRef( );
  221. }
  222. break;
  223. case CCT_RESULT:
  224. // here we can cast from cookie for each node
  225. break;
  226. case CCT_UNINITIALIZED:
  227. // ok thanks
  228. break;
  229. }
  230. return ( *ppDataObject == NULL ) ? E_FAIL : S_OK ;
  231. }
  232. //----------------------------------------------------------------------------------------------------------
  233. // Free all used interfaces
  234. //----------------------------------------------------------------------------------------------------------
  235. STDMETHODIMP CCompdata::Destroy( )
  236. {
  237. if( m_pConsole != NULL )
  238. {
  239. m_pConsole->Release( );
  240. }
  241. if( m_pConsoleNameSpace != NULL )
  242. {
  243. m_pConsoleNameSpace->Release( );
  244. }
  245. if( m_pMainRoot[ 0 ] != NULL )
  246. {
  247. DWORD dwRef = m_pMainRoot[ 0 ]->Release( );
  248. DBGMSG( TEXT("Ref count for main node ended in %d\n" ) , dwRef );
  249. }
  250. if( m_pMainRoot[ 1 ] != NULL )
  251. {
  252. DWORD dwRef = m_pMainRoot[ 1 ]->Release( );
  253. DBGMSG( TEXT("Ref count for settings node ended in %d\n" ) , dwRef );
  254. }
  255. int items = m_rnNodes.GetSize( );
  256. for( int idx = 0 ; idx < items; ++idx )
  257. {
  258. CResultNode *pNode = *m_rnNodes.GetAt( idx );
  259. if( pNode != NULL )
  260. {
  261. pNode->FreeServer( );
  262. pNode->Release( );
  263. }
  264. }
  265. m_rnNodes.DeleteArray( );
  266. items = m_rgsNodes.GetSize( );
  267. for( idx = 0 ; idx < items; idx++ )
  268. {
  269. CSettingNode *pNode = *m_rgsNodes.GetAt( idx );
  270. if( pNode != NULL )
  271. {
  272. delete pNode;
  273. }
  274. }
  275. m_rgsNodes.DeleteArray( );
  276. if( m_pCfgcomp != NULL )
  277. {
  278. m_pCfgcomp->Release( );
  279. }
  280. return S_OK;
  281. }
  282. //----------------------------------------------------------------------------------------------------------
  283. // Places our menu items as spec'd
  284. //----------------------------------------------------------------------------------------------------------
  285. STDMETHODIMP CCompdata::AddMenuItems( LPDATAOBJECT pNode , LPCONTEXTMENUCALLBACK pCtxMenu , PLONG plInsertion )
  286. {
  287. TCHAR tchBuffer1[ 128 ];
  288. TCHAR tchBuffer2[ 128 ];
  289. ASSERT( pNode != NULL );
  290. ASSERT( pCtxMenu != NULL );
  291. ASSERT( plInsertion != NULL );
  292. if( pNode != m_pMainRoot[ 0 ] )
  293. {
  294. return S_FALSE;
  295. }
  296. CONTEXTMENUITEM ctxmi;
  297. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_CTXM_NAME , tchBuffer1 , SIZE_OF_BUFFER( tchBuffer1 ) ) );
  298. ctxmi.strName = tchBuffer1;
  299. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_CTXM_STATUS , tchBuffer2 , SIZE_OF_BUFFER( tchBuffer2 ) ) );
  300. ctxmi.strStatusBarText = tchBuffer2;
  301. ctxmi.lCommandID = IDM_CREATECON;
  302. ctxmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP ;
  303. ctxmi.fFlags = 0;
  304. ctxmi.fSpecialFlags = 0;
  305. *plInsertion |= CCM_INSERTIONALLOWED_TOP;
  306. //VERIFY_S( S_OK , pCtxMenu->AddItem( &ctxmi ) );
  307. //ctxmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_NEW;
  308. return pCtxMenu->AddItem( &ctxmi );
  309. }
  310. //----------------------------------------------------------------------------------------------------------
  311. // This is where the wizard will kick off
  312. //----------------------------------------------------------------------------------------------------------
  313. STDMETHODIMP CCompdata::Command( LONG lCommand , LPDATAOBJECT pNode )
  314. {
  315. HWND hMain;
  316. if( pNode != m_pMainRoot[ 0 ] )
  317. {
  318. return S_FALSE;
  319. }
  320. if( lCommand == IDM_CREATECON )
  321. {
  322. // insure that no other connections are being edited
  323. for( int i = 0 ; i < m_rnNodes.GetSize( ); i++ )
  324. {
  325. CResultNode *pNd = *m_rnNodes.GetAt( i );
  326. if( pNd != NULL )
  327. {
  328. if( pNd->m_bEditMode )
  329. {
  330. if( FAILED( m_pConsole->GetMainWindow( &hMain ) ) )
  331. {
  332. hMain = NULL;
  333. }
  334. xxxErrMessage( hMain , IDS_ERR_INEDITMODE , IDS_WARN_TITLE , MB_OK | MB_ICONWARNING );
  335. return E_FAIL;
  336. }
  337. }
  338. }
  339. // check for admin rights.
  340. BOOL bReadOnly;
  341. m_pCfgcomp->IsSessionReadOnly( &bReadOnly );
  342. if( bReadOnly )
  343. {
  344. if( FAILED( m_pConsole->GetMainWindow( &hMain ) ) )
  345. {
  346. hMain = NULL;
  347. }
  348. // report access denied
  349. TscAccessDeniedMsg( hMain );
  350. return S_FALSE;
  351. }
  352. if( !InitDialogObjects( ) )
  353. {
  354. return E_FAIL;
  355. }
  356. BuildWizardPath( );
  357. FreeDialogObjects( );
  358. }
  359. m_pConsole->UpdateAllViews( ( LPDATAOBJECT )m_rnNodes.GetAt( 0 ) , 0 , 0 );
  360. return S_OK;
  361. }
  362. //----------------------------------------------------------------------------------------------------------
  363. // Try to allocate
  364. BOOL CCompdata::InitDialogObjects( )
  365. {
  366. try
  367. {
  368. m_pDlg[ 0 ] = ( CDialogWizBase * )new CWelcome( );
  369. m_pDlg[ 1 ] = ( CDialogWizBase * )new CConType( this );
  370. m_pDlg[ 2 ] = ( CDialogWizBase * )new CSecurity( this );
  371. // m_pDlg[ 3 ] = ( CDialogWizBase * )new CTimeout( );
  372. // m_pDlg[ 4 ] = ( CDialogWizBase * )new CAutoLogon( );
  373. // m_pDlg[ 5 ] = ( CDialogWizBase * )new CInitProg( );
  374. m_pDlg[ 3 ] = ( CDialogWizBase * )new CRemotectrl( );
  375. // m_pDlg[ 7 ] = ( CDialogWizBase * )new CWallPaper( );
  376. m_pDlg[ 4 ] = ( CDialogWizBase * )new CConProp( this );
  377. m_pDlg[ 5 ] = ( CDialogWizBase * )new CLan( this );
  378. m_pDlg[ 6 ] = ( CDialogWizBase * )new CAsync( this );
  379. m_pDlg[ 7 ] = ( CDialogWizBase * )new CFin( this );
  380. }
  381. catch(...)
  382. {
  383. return FALSE;
  384. }
  385. return TRUE;
  386. }
  387. //----------------------------------------------------------------------------------------------------------
  388. BOOL CCompdata::BuildWizardPath( )
  389. {
  390. // build up ms propsheetheader
  391. PROPSHEETPAGE psp;
  392. PROPSHEETHEADER psh;
  393. for( int idx = 0 ; idx < MS_DIALOG_COUNT ; ++idx )
  394. {
  395. if( m_pDlg[ idx ] != NULL )
  396. {
  397. m_pDlg[ idx ]->GetPropertySheetPage( psp );
  398. m_hPages.Insert( CreatePropertySheetPage( &psp ) );
  399. }
  400. }
  401. // obtain clsid of IExtendwizard object
  402. // forward IWizardProvider to object
  403. // add last page CFin
  404. ZeroMemory( &psh , sizeof( PROPSHEETHEADER ) );
  405. psh.dwSize = sizeof( PROPSHEETHEADER );
  406. psh.hInstance = _Module.GetModuleInstance( );
  407. if( m_pConsole != NULL )
  408. {
  409. m_pConsole->GetMainWindow( &psh.hwndParent );
  410. }
  411. //psh.pszCaption = MAKEINTRESOURCE( IDS_WIZARDTITLE ); //NULL
  412. psh.dwFlags = PSH_WIZARD97 | PSH_WATERMARK | PSH_HEADER ;
  413. psh.pszbmWatermark = MAKEINTRESOURCE( IDB_TSCC_LOGO );
  414. psh.pszbmHeader = MAKEINTRESOURCE( IDB_TSCC_ICON );
  415. psh.phpage = m_hPages.ExposeArray( );
  416. psh.nStartPage = 0;
  417. psh.nPages = m_hPages.GetSize( );
  418. PropertySheet( &psh );
  419. return TRUE;
  420. }
  421. //----------------------------------------------------------------------------------------------------------
  422. BOOL CCompdata::FreeDialogObjects( )
  423. {
  424. for( int idx = 0 ; idx < MS_DIALOG_COUNT ; ++idx )
  425. {
  426. if( m_pDlg[ idx ] != NULL )
  427. {
  428. delete m_pDlg[ idx ];
  429. }
  430. }
  431. m_hPages.DeleteArray( );
  432. return TRUE;
  433. }
  434. //----------------------------------------------------------------------------------------------------------
  435. BOOL CCompdata::IsConnectionFolder( LPDATAOBJECT pObject )
  436. {
  437. if( SUCCEEDED( CompareObjects( pObject , m_pMainRoot[ 0 ] ) ) )
  438. {
  439. return TRUE;
  440. }
  441. return FALSE;
  442. }
  443. //----------------------------------------------------------------------------------------------------------
  444. BOOL CCompdata::IsSettingsFolder( LPDATAOBJECT pObject )
  445. {
  446. if( SUCCEEDED( CompareObjects( pObject , m_pMainRoot[ 1 ] ) ) )
  447. {
  448. return TRUE;
  449. }
  450. return FALSE;
  451. }
  452. //----------------------------------------------------------------------------------------------------------
  453. HRESULT CCompdata::UpdateAllResultNodes( )
  454. {
  455. HWND hMain;
  456. if( FAILED( m_pConsole->GetMainWindow( &hMain ) ) )
  457. {
  458. hMain = NULL;
  459. }
  460. int items = m_rnNodes.GetSize( );
  461. for( int idx = 0 ; idx < items; ++idx )
  462. {
  463. CResultNode *pNode = *m_rnNodes.GetAt( idx );
  464. if( pNode != NULL )
  465. {
  466. if( pNode->m_bEditMode )
  467. {
  468. // ErrMessage( NULL , IDS_ERR_INEDITMODE );
  469. xxxErrMessage( hMain , IDS_ERR_INEDITMODE , IDS_WARN_TITLE , MB_OK | MB_ICONWARNING );
  470. return E_FAIL;
  471. }
  472. }
  473. }
  474. HRESULT hr = m_pCfgcomp->Refresh( );
  475. if( FAILED( hr ) )
  476. {
  477. ODS( L"m_pCfgcomp->Refresh - failed\n" );
  478. if( hr == E_ACCESSDENIED )
  479. {
  480. TscAccessDeniedMsg( hMain );
  481. }
  482. else
  483. {
  484. TscGeneralErrMsg( hMain );
  485. }
  486. return hr;
  487. }
  488. for( idx = 0 ; idx < items; ++idx )
  489. {
  490. CResultNode *pNode = *m_rnNodes.GetAt( idx );
  491. if( pNode != NULL )
  492. {
  493. pNode->FreeServer( );
  494. pNode->Release( );
  495. }
  496. }
  497. m_rnNodes.DeleteArray( );
  498. return BuildResultNodes( );
  499. }
  500. //----------------------------------------------------------------------------------------------------------
  501. BOOL IsAppServerMode()
  502. {
  503. OSVERSIONINFOEX osVersionInfo;
  504. DWORDLONG dwlConditionMask = 0;
  505. BOOL fSuiteTerminal = FALSE;
  506. BOOL fSuiteSingleUserTS = FALSE;
  507. ZeroMemory(&osVersionInfo, sizeof(OSVERSIONINFOEX));
  508. osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
  509. osVersionInfo.wSuiteMask = VER_SUITE_TERMINAL;
  510. VER_SET_CONDITION( dwlConditionMask, VER_SUITENAME, VER_AND );
  511. fSuiteTerminal = VerifyVersionInfo(&osVersionInfo, VER_SUITENAME,
  512. dwlConditionMask);
  513. osVersionInfo.wSuiteMask = VER_SUITE_SINGLEUSERTS;
  514. fSuiteSingleUserTS = VerifyVersionInfo(&osVersionInfo, VER_SUITENAME,
  515. dwlConditionMask);
  516. if( (FALSE == fSuiteSingleUserTS) && (TRUE == fSuiteTerminal) )
  517. {
  518. return TRUE;
  519. }
  520. else
  521. {
  522. return FALSE;
  523. }
  524. }
  525. //----------------------------------------------------------------------------------------------------------
  526. HRESULT CCompdata::BuildSettingsNodes( )
  527. {
  528. // Resource ID for item move to snodes.h
  529. //INT rgResid[] = {
  530. // IDS_DELTEMPONEXIT,
  531. // IDS_USETEMPDIR,
  532. /* IDS_DEFCONSEC, */
  533. // IDS_LICENSING,
  534. // IDS_ADS_ATTR,
  535. // IDS_USERPERM,
  536. // IDS_SINGLE_SESSION,
  537. // -1};
  538. DWORD dwNumItems = sizeof( RGRESID ) / sizeof( RGRESID[0] );
  539. BOOL bAdvanceServer = IsWhistlerAdvanceServer();
  540. BOOL bAppSrvMode = FALSE;
  541. TCHAR tchbuffer[ 256 ];
  542. TCHAR tchKey[ ] = L"Software\\Microsoft\\TSCC\\CLSID";
  543. HKEY hKey;
  544. DWORD dwStatus;
  545. TCHAR szSubKeyName[ 256 ];
  546. DWORD dwSubKeyNameLength;
  547. CLSID clsidOther;
  548. INT nObjectId = 0;
  549. ISettingsComp *pSettings = NULL;
  550. IExtendServerSettings *pExtendServerSettings = NULL;
  551. if( m_pCfgcomp == NULL || FAILED( m_pCfgcomp->QueryInterface( IID_ISettingsComp , ( PVOID * )&pSettings ) ) )
  552. {
  553. return E_FAIL;
  554. }
  555. ASSERT( sizeof( RGRESID ) / sizeof( RGRESID[0] ) == sizeof(VALIDOBJECTONSERVER)/sizeof(VALIDOBJECTONSERVER[0]) );
  556. ASSERT( sizeof(VALIDOBJECTONSERVER)/sizeof(VALIDOBJECTONSERVER[0]) == sizeof(VALIDOBJECTONADS)/sizeof(VALIDOBJECTONADS[0]) );
  557. for( DWORD idx = 0; idx < dwNumItems ; idx++ )
  558. {
  559. // error checking, do go over array boundary
  560. if( !bAdvanceServer )
  561. {
  562. if( idx > sizeof(VALIDOBJECTONSERVER)/sizeof(VALIDOBJECTONSERVER[0]) )
  563. {
  564. ASSERT(FALSE);
  565. continue;
  566. }
  567. }
  568. else
  569. {
  570. if( idx > sizeof(VALIDOBJECTONADS)/sizeof(VALIDOBJECTONADS[0]) )
  571. {
  572. ASSERT(FALSE);
  573. continue;
  574. }
  575. }
  576. if( ( bAdvanceServer && VALIDOBJECTONADS[idx] ) || (!bAdvanceServer && VALIDOBJECTONSERVER[idx] ) )
  577. {
  578. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , RGRESID[ idx ] , tchbuffer , SIZE_OF_BUFFER( tchbuffer ) ) );
  579. // ASSERT( idx < MAX_SETTINGS );
  580. CSettingNode *pSet = ( CSettingNode * )new CSettingNode( );
  581. if( pSet != NULL )
  582. {
  583. pSet->SetObjectId( nObjectId );
  584. pSet->SetInterface( ( LPUNKNOWN )pSettings );
  585. if( !pSet->SetAttributeName( tchbuffer ) )
  586. {
  587. ODS( L"TSCC: BuildSettingsNodes -- SetItemName failed\n" );
  588. }
  589. m_rgsNodes.Insert( pSet );
  590. nObjectId++;
  591. }
  592. }
  593. else
  594. {
  595. nObjectId++;
  596. }
  597. }
  598. pSettings->Release( );
  599. // Find out how many extension nodes are out there.
  600. // First we need to get the specific tssd component supplied for session
  601. // directory services, but only on application servers.
  602. bAppSrvMode = IsAppServerMode();
  603. if( bAppSrvMode && ( dwStatus = RegOpenKeyEx( HKEY_LOCAL_MACHINE ,
  604. REG_CONTROL_TSERVER ,
  605. 0,
  606. KEY_READ,
  607. &hKey ) ) == ERROR_SUCCESS )
  608. {
  609. DBGMSG( L"RegOpenKeyEx tssd ok at %s\n" , REG_CONTROL_TSERVER );
  610. dwSubKeyNameLength = sizeof( szSubKeyName );
  611. dwStatus = RegQueryValueEx( hKey ,
  612. REG_TS_SESSDIRCLSID ,
  613. NULL ,
  614. NULL ,
  615. ( LPBYTE )szSubKeyName ,
  616. &dwSubKeyNameLength );
  617. DBGMSG( L"tssd RegQueryValueEx for %s\n" , REG_TS_SESSDIRCLSID );
  618. DBGMSG( L"tssd RegQueryValueEx ret 0x%x\n" , dwStatus );
  619. if( dwStatus == ERROR_SUCCESS )
  620. {
  621. DBGMSG( L"CCompdata!BuildSettingsNode key name %s\n" , szSubKeyName );
  622. if( SUCCEEDED( CLSIDFromString( szSubKeyName , &clsidOther ) ) )
  623. {
  624. if( SUCCEEDED( CoCreateInstance(
  625. clsidOther ,
  626. NULL ,
  627. CLSCTX_INPROC_SERVER ,
  628. IID_IExtendServerSettings ,
  629. ( LPVOID *) &pExtendServerSettings ) ) )
  630. {
  631. if( pExtendServerSettings != NULL )
  632. {
  633. CSettingNode *pSet = ( CSettingNode * )new CSettingNode( );
  634. if( pSet != NULL )
  635. {
  636. pSet->SetObjectId( nObjectId );
  637. pSet->SetInterface( ( LPUNKNOWN )pExtendServerSettings );
  638. pExtendServerSettings->GetAttributeName( tchbuffer );
  639. if( !pSet->SetAttributeName( tchbuffer ) )
  640. {
  641. ODS( L"TSCC: BuildSettingsNodes -- SetItemName failed\n" );
  642. }
  643. m_rgsNodes.Insert( pSet );
  644. nObjectId++;
  645. }
  646. }
  647. pExtendServerSettings->Release();
  648. }
  649. }
  650. }
  651. RegCloseKey( hKey );
  652. }
  653. // look for other custom components at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\TSCC\CLSID
  654. idx = 0;
  655. if( ( dwStatus = RegOpenKeyEx( HKEY_LOCAL_MACHINE ,
  656. tchKey ,
  657. 0,
  658. KEY_READ,
  659. &hKey ) ) == ERROR_SUCCESS )
  660. {
  661. while( dwStatus == ERROR_SUCCESS )
  662. {
  663. dwSubKeyNameLength = SIZE_OF_BUFFER( szSubKeyName );
  664. dwStatus = RegEnumKeyEx(
  665. hKey ,
  666. ( DWORD )idx,
  667. szSubKeyName ,
  668. &dwSubKeyNameLength,
  669. NULL ,
  670. NULL ,
  671. NULL ,
  672. NULL
  673. );
  674. if( dwStatus != ERROR_SUCCESS )
  675. {
  676. DBGMSG( L"RegEnumKeyEx failed with 0x%x\n" , dwStatus );
  677. break;
  678. }
  679. DBGMSG( L"CCompdata!BuildSettingsNode key name %s\n" , szSubKeyName );
  680. idx++;
  681. if( FAILED( CLSIDFromString( szSubKeyName , &clsidOther ) ) )
  682. {
  683. continue;
  684. }
  685. if( SUCCEEDED( CoCreateInstance(
  686. clsidOther ,
  687. NULL ,
  688. CLSCTX_INPROC_SERVER ,
  689. IID_IExtendServerSettings ,
  690. ( LPVOID *) &pExtendServerSettings ) ) )
  691. {
  692. if( pExtendServerSettings != NULL )
  693. {
  694. CSettingNode *pSet = ( CSettingNode * )new CSettingNode( );
  695. if( pSet != NULL )
  696. {
  697. pSet->SetObjectId( nObjectId );
  698. pSet->SetInterface( ( LPUNKNOWN )pExtendServerSettings );
  699. pExtendServerSettings->GetAttributeName( tchbuffer );
  700. if( !pSet->SetAttributeName( tchbuffer ) )
  701. {
  702. ODS( L"TSCC: BuildSettingsNodes -- SetItemName failed\n" );
  703. }
  704. m_rgsNodes.Insert( pSet );
  705. nObjectId++;
  706. }
  707. }
  708. pExtendServerSettings->Release();
  709. }
  710. } // while
  711. RegCloseKey( hKey );
  712. } // if
  713. return S_OK;
  714. }
  715. //----------------------------------------------------------------------------------------------------------
  716. HRESULT CCompdata::BuildResultNodes( )
  717. {
  718. CResultNode *pResultNode;
  719. WS *pWs;
  720. ULONG ulitems = 0;
  721. ULONG cbSize = 0;
  722. ULONG cItems = 0;
  723. BOOL bValid = TRUE;
  724. PGUIDTBL pGuidtbl = NULL;
  725. TCHAR szOldPdName[ MAX_PATH ];
  726. HRESULT hr = E_FAIL;
  727. if( SUCCEEDED( m_pCfgcomp->GetWinstationList( &ulitems , &cbSize , &pWs ) ) )
  728. {
  729. // Get valid lanids
  730. for( ULONG i = 0 ; i < ulitems ; ++i )
  731. {
  732. // do not list console
  733. if( lstrcmpi( pWs[ i ].Name , L"console" ) == 0 )
  734. {
  735. continue;
  736. }
  737. pResultNode = new CResultNode( );
  738. if( pResultNode == NULL )
  739. {
  740. return E_OUTOFMEMORY;
  741. }
  742. pResultNode->SetConName( pWs[ i ].Name , lstrlen( pWs[ i ].Name ) );
  743. pResultNode->SetTTName( pWs[ i ].pdName , lstrlen( pWs[ i ].pdName ) );
  744. pResultNode->SetTypeName( pWs[ i ].wdName , lstrlen( pWs[ i ].wdName ) );
  745. pResultNode->SetComment( pWs[ i ].Comment , lstrlen( pWs[ i ].Comment ) );
  746. pResultNode->EnableConnection( pWs[ i ].fEnableWinstation );
  747. pResultNode->SetImageIdx( ( pWs[ i ].fEnableWinstation ? 1 : 2 ) );
  748. pResultNode->SetServer( m_pCfgcomp );
  749. if( lstrcmpi( pWs[i].pdName , szOldPdName ) != 0 )
  750. {
  751. if( pGuidtbl != NULL )
  752. {
  753. CoTaskMemFree( pGuidtbl );
  754. pGuidtbl = NULL;
  755. }
  756. hr = m_pCfgcomp->GetLanAdapterList2( pWs[ i ].pdName , &cItems , &pGuidtbl );
  757. lstrcpy( szOldPdName , pWs[i].pdName );
  758. }
  759. if( pGuidtbl != NULL && SUCCEEDED( hr ) )
  760. {
  761. BOOL bFoundaMatch = FALSE;
  762. for( int k = 0; k < ( int )cItems ; ++k )
  763. {
  764. if( ( pGuidtbl[ k ].dwStatus == ERROR_SUCCESS ) && ( pGuidtbl[ k ].dwLana == pWs[ i ].LanAdapter ) )
  765. {
  766. bFoundaMatch = TRUE;
  767. break;
  768. }
  769. }
  770. if( !bFoundaMatch )
  771. {
  772. DWORD dwStatus;
  773. ODS( L"TSCC:BuildResultNodes we found an invalid lanaid\n" );
  774. pWs[ i ].fEnableWinstation = 0;
  775. m_pCfgcomp->UpDateWS( pWs , UPDATE_ENABLEWINSTATION , &dwStatus, TRUE );
  776. pResultNode->EnableConnection( 0 );
  777. pResultNode->SetImageIdx( 2 );
  778. }
  779. if( bValid ) // once set to false we know we have a winstation that has an invalid lanaid
  780. {
  781. bValid = bFoundaMatch;
  782. }
  783. }
  784. if( m_rnNodes.Insert( pResultNode ) == 0 )
  785. {
  786. return E_OUTOFMEMORY;
  787. }
  788. }
  789. if( pGuidtbl != NULL )
  790. {
  791. CoTaskMemFree( pGuidtbl );
  792. }
  793. CoTaskMemFree( pWs );
  794. if( !bValid )
  795. {
  796. HWND hwnd;
  797. BOOL bReadOnly = FALSE;
  798. m_pCfgcomp->IsSessionReadOnly( &bReadOnly );
  799. if( bReadOnly )
  800. {
  801. return S_OK;
  802. }
  803. if( m_pConsole != NULL )
  804. {
  805. m_pConsole->GetMainWindow( &hwnd );
  806. DWORD dwTid;
  807. HANDLE hThread = CreateThread( NULL , 0 , ( LPTHREAD_START_ROUTINE )InitWarningThread, hwnd , 0 , &dwTid );
  808. CloseHandle( hThread );
  809. }
  810. }
  811. return S_OK;
  812. }
  813. return E_FAIL;
  814. }
  815. //----------------------------------------------------------------------------------------------------------
  816. //BOOL CCompdata::GetResultNode( int idx , CResultNode** pRn )
  817. CResultNode * CCompdata::GetResultNode( int idx )
  818. {
  819. return *m_rnNodes.GetAt( idx );
  820. /*
  821. if( *pRn == NULL )
  822. {
  823. return FALSE;
  824. }
  825. return TRUE;
  826. */
  827. }
  828. //----------------------------------------------------------------------------------------------------------
  829. HRESULT CCompdata::InsertSettingItems( LPRESULTDATA pResultData )
  830. {
  831. RESULTDATAITEM rdi;
  832. HRESULT hr;
  833. CSettingNode *pSettingNode = NULL;
  834. ASSERT( pResultData != NULL );
  835. if( pResultData == NULL )
  836. {
  837. return E_INVALIDARG;
  838. }
  839. ZeroMemory( &rdi , sizeof(RESULTDATAITEM) );
  840. rdi.mask = RDI_STR | RDI_PARAM | RDI_IMAGE;
  841. rdi.str = MMC_CALLBACK;
  842. if (NULL != m_pCfgcomp)
  843. {
  844. DWORD nVal, dwStatus;
  845. ISettingsComp* pISettingComp = NULL;
  846. hr = m_pCfgcomp->QueryInterface( IID_ISettingsComp, (void **) &pISettingComp );
  847. if (SUCCEEDED(hr))
  848. {
  849. hr = pISettingComp->GetTermSrvMode( &nVal, &dwStatus );
  850. if (SUCCEEDED(hr))
  851. {
  852. g_bAppSrvMode = nVal;
  853. }
  854. pISettingComp->Release();
  855. }
  856. }
  857. int nMax = m_rgsNodes.GetSize();
  858. for( int idx = 0 ; idx < nMax ; ++idx )
  859. {
  860. // init object -- if it fails skip over it
  861. pSettingNode = *m_rgsNodes.GetAt( idx );
  862. if( pSettingNode != NULL )
  863. {
  864. if( FAILED( pSettingNode->GetNodeStatus( ) ) )
  865. {
  866. continue;
  867. }
  868. /*
  869. if( m_rgsNodes[ idx ].GetObjectId() == USERSECURITY )
  870. {
  871. // check to see if we're remote admin mode
  872. // if so skip over usersecurity
  873. if( !bDisplayUserPerm )
  874. {
  875. continue;
  876. }
  877. }
  878. */
  879. rdi.itemID = 1; // unique from connection items
  880. rdi.lParam = ( LPARAM )pSettingNode;
  881. rdi.nImage = pSettingNode->GetImageIdx( );
  882. hr = pResultData->InsertItem( &rdi );
  883. if( FAILED( hr ) )
  884. {
  885. return hr;
  886. }
  887. }
  888. }
  889. return S_OK;
  890. }
  891. //----------------------------------------------------------------------------------------------------------
  892. HRESULT CCompdata::InsertFolderItems( LPRESULTDATA pResultData )
  893. {
  894. RESULTDATAITEM rdi;
  895. HRESULT hr;
  896. // TCHAR tchBuffer[80];
  897. ASSERT( pResultData != NULL );
  898. if( pResultData == NULL )
  899. {
  900. return E_INVALIDARG;
  901. }
  902. ZeroMemory( &rdi , sizeof(RESULTDATAITEM) );
  903. rdi.mask = RDI_STR | RDI_PARAM | RDI_IMAGE;
  904. rdi.str = MMC_CALLBACK;
  905. int items = m_rnNodes.GetSize( );
  906. for( int idx = 0 ; idx < items ; ++idx )
  907. {
  908. CResultNode *pNode = *m_rnNodes.GetAt( idx );
  909. if( pNode == NULL )
  910. {
  911. return E_FAIL;
  912. }
  913. rdi.lParam = ( LPARAM )pNode;
  914. rdi.nImage = pNode->GetImageIdx( );
  915. hr = pResultData->InsertItem( &rdi );
  916. if( FAILED( hr ) )
  917. {
  918. return hr;
  919. }
  920. }
  921. return S_OK;
  922. }
  923. //----------------------------------------------------------------------------------------------------------
  924. int CCompdata::GetServer( ICfgComp **ppCfgcomp )
  925. {
  926. if( m_pCfgcomp != NULL )
  927. {
  928. *ppCfgcomp = m_pCfgcomp;
  929. return ( ( ICfgComp * )*ppCfgcomp )->AddRef( );
  930. }
  931. return 0;
  932. }
  933. //----------------------------------------------------------------------------------------------------------
  934. BOOL CCompdata::OnDeleteItem( LPDATAOBJECT pDo)
  935. {
  936. ICfgComp *pCfgcomp;
  937. CResultNode *pNode = dynamic_cast< CResultNode *>( pDo );
  938. if( pNode != NULL )
  939. {
  940. HWND hWnd = NULL;
  941. m_pConsole->GetMainWindow( &hWnd );
  942. if( pNode->GetServer( &pCfgcomp ) == 0 )
  943. {
  944. return FALSE;
  945. }
  946. TCHAR tchWarnText[ 512 ];
  947. TCHAR tchmsg[ 256 ];
  948. TCHAR tchDeleteTitle[ 80 ];
  949. LONG lCount;
  950. // check to see if anyone is connected
  951. pCfgcomp->QueryLoggedOnCount( pNode->GetConName( ) , &lCount );
  952. if( lCount > 0 )
  953. {
  954. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_DELETELIVECON , tchmsg , SIZE_OF_BUFFER( tchmsg ) ) );
  955. wsprintf( tchWarnText , tchmsg , pNode->GetConName( ) );
  956. }
  957. else
  958. {
  959. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_DELETETEXT , tchWarnText , SIZE_OF_BUFFER( tchWarnText ) ) );
  960. }
  961. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_DELTITLE , tchDeleteTitle , SIZE_OF_BUFFER( tchDeleteTitle ) ) );
  962. if( MessageBox( hWnd , tchWarnText , tchDeleteTitle , MB_YESNO | MB_ICONEXCLAMATION ) == IDNO )
  963. {
  964. return FALSE;
  965. }
  966. if( FAILED( pCfgcomp->DeleteWS( pNode->GetConName( ) ) ) )
  967. {
  968. // WARN USER
  969. ErrMessage( hWnd , IDS_ERR_DELFAIL );
  970. return FALSE;
  971. }
  972. else
  973. {
  974. VERIFY_S( S_OK , pCfgcomp->ForceUpdate( ) );
  975. }
  976. pCfgcomp->Release( );
  977. }
  978. BOOL bFound;
  979. int idx = m_rnNodes.FindItem( pNode , bFound );
  980. if( bFound )
  981. {
  982. pNode->FreeServer( );
  983. pNode->Release( );
  984. m_rnNodes.DeleteItemAt( idx );
  985. }
  986. m_pConsole->UpdateAllViews( ( LPDATAOBJECT )m_rnNodes.GetAt( 0 ) , 0 , 0 );
  987. return TRUE;
  988. }
  989. //----------------------------------------------------------------------------------------------------------
  990. // MMC Free up ppStr when it's done
  991. //----------------------------------------------------------------------------------------------------------
  992. STDMETHODIMP CCompdata::GetSnapinDescription( LPOLESTR *ppStr )
  993. {
  994. TCHAR tchDescription[ 1024 ];
  995. int iCharCount = LoadString( _Module.GetResourceInstance( ) , IDS_DESCRIPTION , tchDescription , SIZE_OF_BUFFER( tchDescription ) );
  996. *ppStr = ( LPOLESTR )CoTaskMemAlloc( iCharCount * sizeof( TCHAR ) + sizeof( TCHAR ) );
  997. if( *ppStr != NULL )
  998. {
  999. lstrcpy( *ppStr , tchDescription );
  1000. return S_OK;
  1001. }
  1002. return E_OUTOFMEMORY;
  1003. }
  1004. //----------------------------------------------------------------------------------------------------------
  1005. // MMC Free up ppStr when it's done
  1006. //----------------------------------------------------------------------------------------------------------
  1007. STDMETHODIMP CCompdata::GetProvider( LPOLESTR *ppStr )
  1008. {
  1009. TCHAR tchProvider[ 128 ];
  1010. int iCharCount = LoadString( _Module.GetResourceInstance( ) , IDS_PROVIDER , tchProvider , SIZE_OF_BUFFER( tchProvider ) );
  1011. *ppStr = ( LPOLESTR )CoTaskMemAlloc( iCharCount * sizeof( TCHAR ) + sizeof( TCHAR ) );
  1012. if( *ppStr != NULL )
  1013. {
  1014. lstrcpy( *ppStr , tchProvider );
  1015. return S_OK;
  1016. }
  1017. return E_OUTOFMEMORY;
  1018. }
  1019. //----------------------------------------------------------------------------------------------------------
  1020. // MMC Free up ppStr when it's done
  1021. //----------------------------------------------------------------------------------------------------------
  1022. STDMETHODIMP CCompdata::GetSnapinVersion( LPOLESTR *ppStr )
  1023. {
  1024. char chVersion[ 32 ] = VER_PRODUCTVERSION_STR;
  1025. TCHAR tchVersion[ 32 ];
  1026. int iCharCount = MultiByteToWideChar( CP_ACP , 0 , chVersion , sizeof( chVersion ) , tchVersion , SIZE_OF_BUFFER( tchVersion ) );
  1027. *ppStr = ( LPOLESTR )CoTaskMemAlloc( ( iCharCount + 1 ) * sizeof( TCHAR ) );
  1028. if( *ppStr != NULL && iCharCount != 0 )
  1029. {
  1030. lstrcpy( *ppStr , tchVersion );
  1031. return S_OK;
  1032. }
  1033. return E_OUTOFMEMORY;
  1034. }
  1035. //----------------------------------------------------------------------------------------------------------
  1036. // Supply an icon here for the main icon in the about box
  1037. //----------------------------------------------------------------------------------------------------------
  1038. STDMETHODIMP CCompdata::GetSnapinImage( HICON *phIcon )
  1039. {
  1040. //*phIcon = ( HICON )LoadImage( _Module.GetResourceInstance( ) , MAKEINTRESOURCE( IDI_ICON_ABOUT ) , IMAGE_ICON , 37 ,37 , LR_DEFAULTCOLOR );
  1041. *phIcon = ( HICON )LoadImage( _Module.GetResourceInstance( ) , MAKEINTRESOURCE( IDI_ICON_GENERAL2 ) , IMAGE_ICON , 32 ,32 , LR_DEFAULTCOLOR );
  1042. return S_OK;
  1043. }
  1044. //----------------------------------------------------------------------------------------------------------
  1045. // Supply an icon here for the main icon in the about box
  1046. //----------------------------------------------------------------------------------------------------------
  1047. STDMETHODIMP CCompdata::GetStaticFolderImage( HBITMAP *phSmallImage , HBITMAP *phSmallImageOpen , HBITMAP *phLargeImage, COLORREF *pClr )
  1048. {
  1049. *phSmallImage = ( HBITMAP )LoadImage( _Module.GetResourceInstance( ) , MAKEINTRESOURCE( IDB_BITMAP_GENSMALL ) , IMAGE_BITMAP , 16 ,16 , LR_DEFAULTCOLOR );
  1050. *phSmallImageOpen = ( HBITMAP )LoadImage( _Module.GetResourceInstance( ) , MAKEINTRESOURCE( IDB_BITMAP_GENSMALL ) , IMAGE_BITMAP , 16 ,16 , LR_DEFAULTCOLOR );
  1051. *phLargeImage = ( HBITMAP )LoadImage( _Module.GetResourceInstance( ) , MAKEINTRESOURCE( IDB_BITMAP_GENLARGE ) , IMAGE_BITMAP , 32 ,32 , LR_DEFAULTCOLOR );
  1052. *pClr = RGB( 255 , 0 , 255 );
  1053. //return E_NOTIMPL;
  1054. return S_OK;
  1055. }
  1056. //----------------------------------------------------------------------------------------------------------
  1057. // MMC will ask for our help file
  1058. //----------------------------------------------------------------------------------------------------------
  1059. STDMETHODIMP CCompdata::GetHelpTopic( LPOLESTR *ppszHelpFile )
  1060. {
  1061. ODS( L"CCompdata::GetHelpTopic called\n" );
  1062. if( ppszHelpFile == NULL )
  1063. {
  1064. return E_INVALIDARG;
  1065. }
  1066. TCHAR tchHelpFile[ MAX_PATH ];
  1067. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_TSCCSNAPHELP , tchHelpFile , SIZE_OF_BUFFER( tchHelpFile ) ) );
  1068. // mmc will call CoTaskMemFree
  1069. *ppszHelpFile = ( LPOLESTR )CoTaskMemAlloc( sizeof( tchHelpFile ) );
  1070. if( *ppszHelpFile != NULL )
  1071. {
  1072. if( GetSystemWindowsDirectory( *ppszHelpFile , MAX_PATH ) != 0 )
  1073. {
  1074. lstrcat( *ppszHelpFile , tchHelpFile );
  1075. }
  1076. else
  1077. {
  1078. lstrcpy( *ppszHelpFile , tchHelpFile );
  1079. }
  1080. ODS( *ppszHelpFile );
  1081. ODS( L"\n" );
  1082. return S_OK;
  1083. }
  1084. return E_OUTOFMEMORY;
  1085. }
  1086. //----------------------------------------------------------------------------------------------------------
  1087. // Helper methods for fixing the column lengths
  1088. //----------------------------------------------------------------------------------------------------------
  1089. BOOL CCompdata::GetMaxTextLengthSetting( LPTSTR pszText , PINT pnMaxLen )
  1090. {
  1091. INT nIndex = 0;
  1092. INT nCurrentMax = 0;
  1093. INT nMax;
  1094. *pnMaxLen = 0;
  1095. nMax = m_rgsNodes.GetSize( );
  1096. CSettingNode *pSettingNode;
  1097. for( int idx = 0 ; idx < nMax ; ++idx )
  1098. {
  1099. pSettingNode = *m_rgsNodes.GetAt( idx );
  1100. if( pSettingNode != NULL && pSettingNode->GetAttributeName( ) != NULL )
  1101. {
  1102. nCurrentMax = lstrlen( pSettingNode->GetAttributeName( ) );
  1103. if( *pnMaxLen < nCurrentMax )
  1104. {
  1105. *pnMaxLen = nCurrentMax;
  1106. nIndex = idx;
  1107. }
  1108. }
  1109. }
  1110. pSettingNode = *m_rgsNodes.GetAt( nIndex );
  1111. if (pSettingNode != NULL && pSettingNode->GetAttributeName( ) != NULL)
  1112. {
  1113. lstrcpy( pszText , pSettingNode->GetAttributeName( ) );
  1114. }
  1115. return TRUE;
  1116. }
  1117. //----------------------------------------------------------------------------------------------------------
  1118. // Helper methods for fixing the column lengths
  1119. //----------------------------------------------------------------------------------------------------------
  1120. BOOL CCompdata::GetMaxTextLengthAttribute( LPTSTR pszText , PINT pnMaxLen )
  1121. {
  1122. INT nIndex = 0;
  1123. INT nCurrentMax = 0;
  1124. INT nMax;
  1125. *pnMaxLen = 0;
  1126. nMax = m_rgsNodes.GetSize( );
  1127. CSettingNode *pSettingNode = NULL;
  1128. for( int idx = 0 ; idx < nMax ; ++idx )
  1129. {
  1130. pSettingNode = *m_rgsNodes.GetAt( idx );
  1131. if (pSettingNode != NULL && pSettingNode->GetAttributeName( ) != NULL )
  1132. {
  1133. nCurrentMax = lstrlen( pSettingNode->GetAttributeValue( ) );
  1134. DBGMSG( L"CCompdata!GetMaxTextLengthAttribute AttributeValue = %s\n", pSettingNode->GetAttributeValue( ) );
  1135. if( *pnMaxLen < nCurrentMax )
  1136. {
  1137. *pnMaxLen = nCurrentMax;
  1138. nIndex = idx;
  1139. }
  1140. }
  1141. }
  1142. pSettingNode = *m_rgsNodes.GetAt( nIndex );
  1143. if (pSettingNode != NULL)
  1144. {
  1145. LPTSTR pszValue = pSettingNode->GetAttributeValue( );
  1146. if(pszValue != NULL)
  1147. {
  1148. lstrcpy( pszText , pszValue );
  1149. }
  1150. else
  1151. {
  1152. return FALSE;
  1153. }
  1154. }
  1155. return TRUE;
  1156. }
  1157. void InitWarningThread( PVOID pvParam )
  1158. {
  1159. HWND hwnd = ( HWND )pvParam;
  1160. TCHAR tchMessage[ 256 ];
  1161. TCHAR tchTitle[ 80 ];
  1162. Sleep( 200 );
  1163. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_DISABNETWORK , tchMessage , SIZE_OF_BUFFER( tchMessage ) ) );
  1164. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_TSCERRTITLE , tchTitle , SIZE_OF_BUFFER( tchTitle ) ) );
  1165. MessageBox( hwnd , tchMessage , tchTitle , MB_ICONINFORMATION | MB_OK );
  1166. }