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.

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