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.

1147 lines
30 KiB

  1. /*******************************************************************************
  2. *
  3. * winspgs.cpp
  4. *
  5. * implementations for the WinStation info pages
  6. *
  7. * copyright notice: Copyright 1997, Citrix Systems Inc.
  8. * Copyright (c) 1998 - 1999 Microsoft Corporation
  9. *
  10. * $Author: donm $ Don Messerli
  11. *
  12. * $Log: N:\nt\private\utils\citrix\winutils\tsadmin\VCS\winspgs.cpp $
  13. *
  14. * Rev 1.5 25 Apr 1998 14:32:24 donm
  15. * removed hardcoded 'bytes'
  16. *
  17. * Rev 1.4 16 Feb 1998 16:03:32 donm
  18. * modifications to support pICAsso extension
  19. *
  20. * Rev 1.3 03 Nov 1997 15:18:36 donm
  21. * Added descending sort
  22. *
  23. * Rev 1.2 13 Oct 1997 18:39:04 donm
  24. * update
  25. *
  26. * Rev 1.1 26 Aug 1997 19:15:50 donm
  27. * bug fixes/changes from WinFrame 1.7
  28. *
  29. * Rev 1.0 30 Jul 1997 17:13:38 butchd
  30. * Initial revision.
  31. *
  32. *******************************************************************************/
  33. #include "stdafx.h"
  34. #include "afxpriv.h"
  35. #include "winadmin.h"
  36. #include "admindoc.h"
  37. #include "winspgs.h"
  38. #ifdef _DEBUG
  39. #define new DEBUG_NEW
  40. #undef THIS_FILE
  41. static char THIS_FILE[] = __FILE__;
  42. #endif
  43. ////////////////////////////////
  44. // MESSAGE MAP: CWinStationInfoPage
  45. //
  46. IMPLEMENT_DYNCREATE(CWinStationInfoPage, CFormView)
  47. BEGIN_MESSAGE_MAP(CWinStationInfoPage, CFormView)
  48. //{{AFX_MSG_MAP(CWinStationInfoPage)
  49. //ON_WM_SETFOCUS( )
  50. ON_WM_SIZE()
  51. ON_COMMAND(ID_HELP1,OnCommandHelp)
  52. //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54. /////////////////////////////
  55. // F'N: CWinStationInfoPage ctor
  56. //
  57. CWinStationInfoPage::CWinStationInfoPage()
  58. : CAdminPage(CWinStationInfoPage::IDD)
  59. {
  60. //{{AFX_DATA_INIT(CWinStationInfoPage)
  61. //}}AFX_DATA_INIT
  62. m_pWinStation = NULL;
  63. } // end CWinStationInfoPage ctor
  64. /*
  65. void CWinStationInfoPage::OnSetFocus( )
  66. {
  67. */
  68. /////////////////////////////
  69. // F'N: CWinStationInfoPage dtor
  70. //
  71. CWinStationInfoPage::~CWinStationInfoPage()
  72. {
  73. } // end CWinStationInfoPage dtor
  74. ////////////////////////////////////////
  75. // F'N: CWinStationInfoPage::DoDataExchange
  76. //
  77. void CWinStationInfoPage::DoDataExchange(CDataExchange* pDX)
  78. {
  79. CFormView::DoDataExchange(pDX);
  80. //{{AFX_DATA_MAP(CWinStationInfoPage)
  81. //}}AFX_DATA_MAP
  82. } // end CWinStationInfoPage::DoDataExchange
  83. #ifdef _DEBUG
  84. /////////////////////////////////////
  85. // F'N: CWinStationInfoPage::AssertValid
  86. //
  87. void CWinStationInfoPage::AssertValid() const
  88. {
  89. CFormView::AssertValid();
  90. } // end CWinStationInfoPage::AssertValid
  91. //////////////////////////////
  92. // F'N: CWinStationInfoPage::Dump
  93. //
  94. void CWinStationInfoPage::Dump(CDumpContext& dc) const
  95. {
  96. CFormView::Dump(dc);
  97. } // end CWinStationInfoPage::Dump
  98. #endif //_DEBUG
  99. //////////////////////////////
  100. // F'N: CWinStationInfoPage::OnCommandHelp
  101. //
  102. void CWinStationInfoPage::OnCommandHelp(void)
  103. {
  104. AfxGetApp()->WinHelp(CWinStationInfoPage::IDD + HID_BASE_RESOURCE);
  105. } // end CWinStationInfoPage::OnCommandHelp
  106. //////////////////////////////
  107. // F'N: CWinStationInfoPage::OnInitialUpdate
  108. //
  109. void CWinStationInfoPage::OnInitialUpdate()
  110. {
  111. CFormView::OnInitialUpdate();
  112. } // end CWinStationInfoPage::OnInitialUpdate
  113. //////////////////////////////
  114. // F'N: CWinStationInfoPage::OnSize
  115. //
  116. void CWinStationInfoPage::OnSize(UINT nType, int cx, int cy)
  117. {
  118. //CFormView::OnSize(nType, cx, cy);
  119. } // end CWinStationInfoPage::OnSize
  120. //////////////////////////////
  121. // F'N: CWinStationInfoPage::Reset
  122. //
  123. void CWinStationInfoPage::Reset(void *pWinStation)
  124. {
  125. m_pWinStation = (CWinStation*)pWinStation;
  126. DisplayInfo();
  127. } // end CWinStationInfoPage::Reset
  128. /////////////////////////////////////
  129. // F'N: CWinStationInfoPage::DisplayInfo
  130. //
  131. //
  132. void CWinStationInfoPage::DisplayInfo()
  133. {
  134. // We don't want to display info for the console
  135. // Even though this page is not shown for the console,
  136. // Reset() is still called and therefore, so is this function
  137. if(m_pWinStation->IsSystemConsole()) return;
  138. if(!m_pWinStation->AdditionalDone()) m_pWinStation->QueryAdditionalInformation();
  139. SetDlgItemText(IDC_WS_INFO_USERNAME, m_pWinStation->GetUserName());
  140. SetDlgItemText(IDC_WS_INFO_CLIENTNAME, m_pWinStation->GetClientName());
  141. CString BuildString;
  142. BuildString.Format(TEXT("%lu"), m_pWinStation->GetClientBuildNumber());
  143. SetDlgItemText(IDC_WS_INFO_BUILD, BuildString);
  144. SetDlgItemText(IDC_WS_INFO_DIR, m_pWinStation->GetClientDir());
  145. CString IDString;
  146. IDString.Format(TEXT("%u"), m_pWinStation->GetClientProductId());
  147. SetDlgItemText(IDC_WS_INFO_PRODUCT_ID, IDString);
  148. IDString.Format(TEXT("%lu"), m_pWinStation->GetClientSerialNumber());
  149. SetDlgItemText(IDC_WS_INFO_SERIAL_NUMBER, IDString);
  150. SetDlgItemText(IDC_WS_INFO_ADDRESS, m_pWinStation->GetClientAddress());
  151. CString BufferString;
  152. CString FormatString;
  153. FormatString.LoadString(IDS_BUFFERS_FORMAT);
  154. BufferString.Format(FormatString, m_pWinStation->GetHostBuffers(), m_pWinStation->GetBufferLength());
  155. SetDlgItemText(IDC_WS_INFO_SERVER_BUFFERS, BufferString);
  156. BufferString.Format(FormatString, m_pWinStation->GetClientBuffers(), m_pWinStation->GetBufferLength());
  157. SetDlgItemText(IDC_WS_INFO_CLIENT_BUFFERS, BufferString);
  158. SetDlgItemText(IDC_WS_INFO_MODEM_NAME, m_pWinStation->GetModemName());
  159. SetDlgItemText(IDC_WS_INFO_CLIENT_LICENSE, m_pWinStation->GetClientLicense());
  160. SetDlgItemText(IDC_WS_INFO_COLOR_DEPTH, m_pWinStation->GetColors());
  161. IDString.Format(IDS_CLIENT_RESOLUTION, m_pWinStation->GetHRes(), m_pWinStation->GetVRes());
  162. SetDlgItemText(IDC_WS_INFO_RESOLUTION, IDString);
  163. if(!m_pWinStation->GetEncryptionLevelString(&BuildString)) {
  164. BuildString.LoadString(IDS_NOT_APPLICABLE);
  165. }
  166. SetDlgItemText(IDC_ENCRYPTION_LEVEL, BuildString);
  167. } // end CWinStationInfoPage::DisplayInfo
  168. ////////////////////////////////
  169. // MESSAGE MAP: CWinStationNoInfoPage
  170. //
  171. IMPLEMENT_DYNCREATE(CWinStationNoInfoPage, CFormView)
  172. BEGIN_MESSAGE_MAP(CWinStationNoInfoPage, CFormView)
  173. //{{AFX_MSG_MAP(CWinStationNoInfoPage)
  174. ON_WM_SIZE( )
  175. ON_WM_SETFOCUS( )
  176. //}}AFX_MSG_MAP
  177. END_MESSAGE_MAP()
  178. //=---------------------------------------------------
  179. void CWinStationNoInfoPage::OnSetFocus( CWnd * pOld )
  180. {
  181. ODS( L"CWinStationNoInfoPage::OnSetFocus\n" );
  182. CWnd::OnSetFocus( pOld );
  183. }
  184. /////////////////////////////
  185. // F'N: CWinStationNoInfoPage ctor
  186. //
  187. CWinStationNoInfoPage::CWinStationNoInfoPage()
  188. : CAdminPage(CWinStationNoInfoPage::IDD)
  189. {
  190. //{{AFX_DATA_INIT(CWinStationNoInfoPage)
  191. //}}AFX_DATA_INIT
  192. } // end CWinStationNoInfoPage ctor
  193. void CWinStationNoInfoPage::OnSize( UINT nType, int cx, int cy)
  194. {
  195. //eat it.
  196. }
  197. /////////////////////////////
  198. // F'N: CWinStationNoInfoPage dtor
  199. //
  200. CWinStationNoInfoPage::~CWinStationNoInfoPage()
  201. {
  202. } // end CWinStationNoInfoPage dtor
  203. ////////////////////////////////////////
  204. // F'N: CWinStationNoInfoPage::DoDataExchange
  205. //
  206. void CWinStationNoInfoPage::DoDataExchange(CDataExchange* pDX)
  207. {
  208. CFormView::DoDataExchange(pDX);
  209. //{{AFX_DATA_MAP(CWinStationNoInfoPage)
  210. //}}AFX_DATA_MAP
  211. } // end CWinStationNoInfoPage::DoDataExchange
  212. #ifdef _DEBUG
  213. /////////////////////////////////////
  214. // F'N: CWinStationNoInfoPage::AssertValid
  215. //
  216. void CWinStationNoInfoPage::AssertValid() const
  217. {
  218. CFormView::AssertValid();
  219. } // end CWinStationNoInfoPage::AssertValid
  220. //////////////////////////////
  221. // F'N: CWinStationNoInfoPage::Dump
  222. //
  223. void CWinStationNoInfoPage::Dump(CDumpContext& dc) const
  224. {
  225. CFormView::Dump(dc);
  226. } // end CWinStationNoInfoPage::Dump
  227. #endif //_DEBUG
  228. ////////////////////////////////
  229. // MESSAGE MAP: CWinStationModulesPage
  230. //
  231. IMPLEMENT_DYNCREATE(CWinStationModulesPage, CFormView)
  232. BEGIN_MESSAGE_MAP(CWinStationModulesPage, CFormView)
  233. //{{AFX_MSG_MAP(CWinStationModulesPage)
  234. ON_WM_SIZE()
  235. ON_NOTIFY(LVN_COLUMNCLICK, IDC_WINSTATION_MODULE_LIST, OnColumnClick)
  236. ON_NOTIFY(NM_SETFOCUS, IDC_WINSTATION_MODULE_LIST, OnSetfocusModuleList)
  237. //}}AFX_MSG_MAP
  238. END_MESSAGE_MAP()
  239. /////////////////////////////
  240. // F'N: CWinStationModulesPage ctor
  241. //
  242. CWinStationModulesPage::CWinStationModulesPage()
  243. : CAdminPage(CWinStationModulesPage::IDD)
  244. {
  245. //{{AFX_DATA_INIT(CWinStationModulesPage)
  246. //}}AFX_DATA_INIT
  247. m_pWinStation = NULL;
  248. m_bSortAscending = TRUE;
  249. m_pExtModuleInfo = NULL;
  250. } // end CWinStationModulesPage ctor
  251. /////////////////////////////
  252. // F'N: CWinStationModulesPage dtor
  253. //
  254. CWinStationModulesPage::~CWinStationModulesPage()
  255. {
  256. if(m_pExtModuleInfo) delete[] m_pExtModuleInfo;
  257. } // end CWinStationModulesPage dtor
  258. ////////////////////////////////////////
  259. // F'N: CWinStationModulesPage::DoDataExchange
  260. //
  261. void CWinStationModulesPage::DoDataExchange(CDataExchange* pDX)
  262. {
  263. CFormView::DoDataExchange(pDX);
  264. //{{AFX_DATA_MAP(CWinStationModulesPage)
  265. DDX_Control(pDX, IDC_WINSTATION_MODULE_LIST, m_ModuleList);
  266. //}}AFX_DATA_MAP
  267. } // end CWinStationModulesPage::DoDataExchange
  268. #ifdef _DEBUG
  269. /////////////////////////////////////
  270. // F'N: CWinStationModulesPage::AssertValid
  271. //
  272. void CWinStationModulesPage::AssertValid() const
  273. {
  274. CFormView::AssertValid();
  275. } // end CWinStationModulesPage::AssertValid
  276. //////////////////////////////
  277. // F'N: CWinStationModulesPage::Dump
  278. //
  279. void CWinStationModulesPage::Dump(CDumpContext& dc) const
  280. {
  281. CFormView::Dump(dc);
  282. } // end CWinStationModulesPage::Dump
  283. #endif //_DEBUG
  284. static ColumnDef ModuleColumns[] = {
  285. { IDS_COL_FILENAME, LVCFMT_LEFT, 150 },
  286. { IDS_COL_FILEDATETIME, LVCFMT_LEFT, 100 },
  287. { IDS_COL_SIZE, LVCFMT_RIGHT, 100 },
  288. { IDS_COL_VERSIONS, LVCFMT_RIGHT, 60 }
  289. };
  290. #define NUM_MODULE_COLUMNS sizeof(ModuleColumns)/sizeof(ColumnDef)
  291. //////////////////////////////
  292. // F'N: CWinStationModulesPage::OnInitialUpdate
  293. //
  294. void CWinStationModulesPage::OnInitialUpdate()
  295. {
  296. CFormView::OnInitialUpdate();
  297. BuildImageList(); // builds the image list for the list control
  298. CString columnString;
  299. for(int col = 0; col < NUM_MODULE_COLUMNS; col++) {
  300. columnString.LoadString(ModuleColumns[col].stringID);
  301. m_ModuleList.InsertColumn(col, columnString, ModuleColumns[col].format, ModuleColumns[col].width, col);
  302. }
  303. m_CurrentSortColumn = MODULES_COL_FILENAME;
  304. } // end CWinStationModulesPage::OnInitialUpdate
  305. /////////////////////////////////////
  306. // F'N: CWinStationModulesPage::BuildImageList
  307. //
  308. // - calls m_imageList.Create(..) to create the image list
  309. // - calls AddIconToImageList(..) to add the icons themselves and save
  310. // off their indices
  311. // - attaches the image list to the list ctrl
  312. //
  313. void CWinStationModulesPage::BuildImageList()
  314. {
  315. m_imageList.Create(16, 16, TRUE, 1, 0);
  316. m_idxBlank = AddIconToImageList(IDI_BLANK);
  317. m_ModuleList.SetImageList(&m_imageList, LVSIL_SMALL);
  318. } // end CWinStationModulesPage::BuildImageList
  319. /////////////////////////////////////////
  320. // F'N: CWinStationModulesPage::AddIconToImageList
  321. //
  322. // - loads the appropriate icon, adds it to m_imageList, and returns
  323. // the newly-added icon's index in the image list
  324. //
  325. int CWinStationModulesPage::AddIconToImageList(int iconID)
  326. {
  327. HICON hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(iconID));
  328. return m_imageList.Add(hIcon);
  329. } // end CWinStationModulesPage::AddIconToImageList
  330. //////////////////////////////
  331. // F'N: CWinStationModulesPage::OnColumnClick
  332. //
  333. void CWinStationModulesPage::OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult)
  334. {
  335. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  336. // If the sort column hasn't changed, flip the ascending mode.
  337. if(m_CurrentSortColumn == pNMListView->iSubItem)
  338. m_bSortAscending = !m_bSortAscending;
  339. else // New sort column, start in ascending mode
  340. m_bSortAscending = TRUE;
  341. m_CurrentSortColumn = pNMListView->iSubItem;
  342. SortByColumn(VIEW_WINSTATION, PAGE_WS_MODULES, &m_ModuleList, m_CurrentSortColumn, m_bSortAscending);
  343. *pResult = 0;
  344. } // end CWinStationModulesPage::OnColumnClick
  345. //////////////////////////////
  346. // F'N: CWinStationModulesPage::OnSetfocusModuleList
  347. //
  348. void CWinStationModulesPage::OnSetfocusModuleList(NMHDR* pNMHDR, LRESULT* pResult)
  349. {
  350. m_ModuleList.Invalidate();
  351. *pResult = 0;
  352. } // end CWinStationModulesPage::OnSetfocusModuleList
  353. //////////////////////////////
  354. // F'N: CWinStationModulesPage::OnSize
  355. //
  356. void CWinStationModulesPage::OnSize(UINT nType, int cx, int cy)
  357. {
  358. RECT rect;
  359. GetClientRect(&rect);
  360. rect.top += LIST_TOP_OFFSET;
  361. if(m_ModuleList.GetSafeHwnd())
  362. m_ModuleList.MoveWindow(&rect, TRUE);
  363. //CFormView::OnSize(nType, cx, cy);
  364. } // end CWinStationModulesPage::OnSize
  365. //////////////////////////////
  366. // F'N: CWinStationModulesPage::Reset
  367. //
  368. void CWinStationModulesPage::Reset(void *pWinStation)
  369. {
  370. m_pWinStation = (CWinStation*)pWinStation;
  371. if(m_pExtModuleInfo) delete[] m_pExtModuleInfo;
  372. m_pExtModuleInfo = NULL;
  373. DisplayModules();
  374. } // end CWinStationModulesPage::Reset
  375. /////////////////////////////////////
  376. // F'N: CWinStationModulesPage::DisplayModules
  377. //
  378. //
  379. void CWinStationModulesPage::DisplayModules()
  380. {
  381. // We don't want to display modules for the console
  382. // Even though this page is not shown for the console,
  383. // Reset() is still called and therefore, so is this function
  384. if(m_pWinStation->IsSystemConsole()) return;
  385. // Clear out the list control
  386. m_ModuleList.DeleteAllItems();
  387. if(!m_pWinStation->AdditionalDone()) m_pWinStation->QueryAdditionalInformation();
  388. // If this is an ICA WinStation, display the module information
  389. if(m_pWinStation->GetExtendedInfo()) {
  390. ExtModuleInfo *pExtModuleInfo = m_pWinStation->GetExtModuleInfo();
  391. if(pExtModuleInfo) {
  392. ULONG NumModules = m_pWinStation->GetNumModules();
  393. ExtModuleInfo *pModule = pExtModuleInfo;
  394. for(ULONG module = 0; module < NumModules; module++) {
  395. // Filename - put at the end of the list
  396. int item = m_ModuleList.InsertItem(m_ModuleList.GetItemCount(), pModule->Name, m_idxBlank);
  397. // File date and time
  398. FILETIME fTime;
  399. TCHAR szDateTime[MAX_DATE_TIME_LENGTH];
  400. if(!DosDateTimeToFileTime(pModule->Date, pModule->Time, &fTime))
  401. wcscpy(szDateTime, TEXT(" "));
  402. else
  403. DateTimeString((LARGE_INTEGER *)&fTime, szDateTime);
  404. m_ModuleList.SetItemText(item, MODULES_COL_FILEDATETIME, szDateTime);
  405. // File size
  406. CString SizeString;
  407. if(pModule->Size) SizeString.Format(TEXT("%lu"), pModule->Size);
  408. else SizeString.LoadString(IDS_EMBEDDED);
  409. m_ModuleList.SetItemText(item, MODULES_COL_SIZE, SizeString);
  410. // Versions
  411. CString VersionString;
  412. VersionString.Format(TEXT("%u - %u"), pModule->LowVersion, pModule->HighVersion);
  413. m_ModuleList.SetItemText(item, MODULES_COL_VERSIONS, VersionString);
  414. m_ModuleList.SetItemData(item, (DWORD_PTR)pModule);
  415. pModule++;
  416. }
  417. }
  418. }
  419. } // end CWinStationModulesPage::DisplayModules
  420. ////////////////////////////////
  421. // MESSAGE MAP: CWinStationProcessesPage
  422. //
  423. IMPLEMENT_DYNCREATE(CWinStationProcessesPage, CFormView)
  424. BEGIN_MESSAGE_MAP(CWinStationProcessesPage, CFormView)
  425. //{{AFX_MSG_MAP(CWinStationProcessesPage)
  426. ON_WM_SIZE()
  427. ON_NOTIFY(LVN_COLUMNCLICK, IDC_WINSTATION_PROCESS_LIST, OnColumnClick)
  428. ON_NOTIFY(LVN_ITEMCHANGED, IDC_WINSTATION_PROCESS_LIST, OnProcessItemChanged)
  429. ON_WM_CONTEXTMENU()
  430. ON_NOTIFY(NM_SETFOCUS, IDC_WINSTATION_PROCESS_LIST, OnSetfocusWinstationProcessList)
  431. // ON_NOTIFY(NM_KILLFOCUS , IDC_WINSTATION_PROCESS_LIST , OnKillFocusWinstationProcessList )
  432. //}}AFX_MSG_MAP
  433. END_MESSAGE_MAP()
  434. /////////////////////////////
  435. // F'N: CWinStationProcessesPage ctor
  436. //
  437. CWinStationProcessesPage::CWinStationProcessesPage()
  438. : CAdminPage(CWinStationProcessesPage::IDD)
  439. {
  440. //{{AFX_DATA_INIT(CWinStationProcessesPage)
  441. // NOTE: the ClassWizard will add member initialization here
  442. //}}AFX_DATA_INIT
  443. m_pWinStation = NULL;
  444. m_bSortAscending = TRUE;
  445. } // end CWinStationProcessesPage ctor
  446. /////////////////////////////
  447. // F'N: CWinStationProcessesPage dtor
  448. //
  449. CWinStationProcessesPage::~CWinStationProcessesPage()
  450. {
  451. } // end CWinStationProcessesPage dtor
  452. ////////////////////////////////////////
  453. // F'N: CWinStationProcessesPage::DoDataExchange
  454. //
  455. void CWinStationProcessesPage::DoDataExchange(CDataExchange* pDX)
  456. {
  457. CFormView::DoDataExchange(pDX);
  458. //{{AFX_DATA_MAP(CWinStationProcessesPage)
  459. DDX_Control(pDX, IDC_WINSTATION_PROCESS_LIST, m_ProcessList);
  460. //}}AFX_DATA_MAP
  461. } // end CWinStationProcessesPage::DoDataExchange
  462. #ifdef _DEBUG
  463. /////////////////////////////////////
  464. // F'N: CWinStationProcessesPage::AssertValid
  465. //
  466. void CWinStationProcessesPage::AssertValid() const
  467. {
  468. CFormView::AssertValid();
  469. } // end CWinStationProcessesPage::AssertValid
  470. //////////////////////////////
  471. // F'N: CWinStationProcessesPage::Dump
  472. //
  473. void CWinStationProcessesPage::Dump(CDumpContext& dc) const
  474. {
  475. CFormView::Dump(dc);
  476. } // end CWinStationProcessesPage::Dump
  477. #endif //_DEBUG
  478. //////////////////////////////
  479. // F'N: CWinStationProcessesPage::OnSize
  480. //
  481. void CWinStationProcessesPage::OnSize(UINT nType, int cx, int cy)
  482. {
  483. RECT rect;
  484. GetClientRect(&rect);
  485. rect.top += LIST_TOP_OFFSET;
  486. if(m_ProcessList.GetSafeHwnd())
  487. m_ProcessList.MoveWindow(&rect, TRUE);
  488. //CFormView::OnSize(nType, cx, cy);
  489. } // end CWinStationProcessesPage::OnSize
  490. static ColumnDef ProcColumns[] = {
  491. CD_PROC_ID,
  492. CD_PROC_PID,
  493. CD_PROC_IMAGE
  494. };
  495. #define NUM_PROC_COLUMNS sizeof(ProcColumns)/sizeof(ColumnDef)
  496. //////////////////////////////
  497. // F'N: CWinStationProcessesPage::OnInitialUpdate
  498. //
  499. void CWinStationProcessesPage::OnInitialUpdate()
  500. {
  501. // Call the parent class
  502. CFormView::OnInitialUpdate();
  503. CString columnString;
  504. for(int col = 0; col < NUM_PROC_COLUMNS; col++) {
  505. columnString.LoadString(ProcColumns[col].stringID);
  506. m_ProcessList.InsertColumn(col, columnString, ProcColumns[col].format, ProcColumns[col].width, col);
  507. }
  508. m_CurrentSortColumn = WS_PROC_COL_ID;
  509. // This is a major kludge!!!!
  510. // This is the last view created
  511. // We want to tell the document that all the
  512. // views have been created.
  513. // This is to allow background threads to start
  514. // doing their thing.
  515. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->SetMainWnd(AfxGetMainWnd());
  516. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->SetAllViewsReady();
  517. } // end CWinStationProcessesPage::OnInitialUpdate
  518. //////////////////////////////
  519. // F'N: CWinStationProcessesPage::Reset
  520. //
  521. void CWinStationProcessesPage::Reset(void *pWinStation)
  522. {
  523. m_pWinStation = (CWinStation*)pWinStation;
  524. DisplayProcesses();
  525. } // end CWinStationProcessesPage::Reset
  526. //////////////////////////////
  527. // F'N: CWinStationProcessesPage::UpdateProcesses
  528. //
  529. void CWinStationProcessesPage::UpdateProcesses()
  530. {
  531. CWinAdminApp *pApp = (CWinAdminApp*)AfxGetApp();
  532. BOOL bAnyChanged = FALSE;
  533. BOOL bAnyAdded = FALSE;
  534. CServer *pServer = m_pWinStation->GetServer();
  535. // Loop through the processes
  536. pServer->LockProcessList();
  537. CObList *pProcessList = pServer->GetProcessList();
  538. POSITION pos = pProcessList->GetHeadPosition();
  539. while(pos) {
  540. CProcess *pProcess = (CProcess*)pProcessList->GetNext(pos);
  541. // If this is a 'system' process and we aren't currently showing them,
  542. // go to the next process
  543. if(pProcess->IsSystemProcess() && !pApp->ShowSystemProcesses())
  544. continue;
  545. // If this user is not an Admin, don't show him someone else's processes
  546. if(!pApp->IsUserAdmin() && !pProcess->IsCurrentUsers())
  547. continue;
  548. // We only want to show process for this WinStation
  549. if(pProcess->GetLogonId() == m_pWinStation->GetLogonId()) {
  550. // If the process is new, add it to the list
  551. if(pProcess->IsNew()) {
  552. AddProcessToList(pProcess);
  553. bAnyAdded = TRUE;
  554. continue;
  555. }
  556. LV_FINDINFO FindInfo;
  557. FindInfo.flags = LVFI_PARAM;
  558. FindInfo.lParam = (LPARAM)pProcess;
  559. // Find the Process in our list
  560. int item = m_ProcessList.FindItem(&FindInfo, -1);
  561. // If the process is no longer current,
  562. // remove it from the list
  563. if(!pProcess->IsCurrent() && item != -1) {
  564. // Remove the Process from the list
  565. m_ProcessList.DeleteItem(item);
  566. }
  567. }
  568. }
  569. pServer->UnlockProcessList();
  570. if(bAnyChanged || bAnyAdded) SortByColumn(VIEW_WINSTATION, PAGE_WS_PROCESSES, &m_ProcessList, m_CurrentSortColumn, m_bSortAscending);
  571. } // end CWinStationProcessesPage::UpdateProcesses
  572. //////////////////////////////////////////
  573. // F'N: CWinStationProcessesPage::RemoveProcess
  574. //
  575. void CWinStationProcessesPage::RemoveProcess(CProcess *pProcess)
  576. {
  577. // Find out how many items in the list
  578. int ItemCount = m_ProcessList.GetItemCount();
  579. // Go through the items and remove this process
  580. for(int item = 0; item < ItemCount; item++) {
  581. CProcess *pListProcess = (CProcess*)m_ProcessList.GetItemData(item);
  582. if(pListProcess == pProcess) {
  583. m_ProcessList.DeleteItem(item);
  584. break;
  585. }
  586. }
  587. } // end CWinStationProcessPage::RemoveProcess
  588. //////////////////////////////
  589. // F'N: CWinStationProcessesPage::AddProcessToList
  590. //
  591. int CWinStationProcessesPage::AddProcessToList(CProcess *pProcess)
  592. {
  593. CWinAdminApp *pApp = (CWinAdminApp*)AfxGetApp();
  594. // ID
  595. CString ProcString;
  596. ProcString.Format(TEXT("%lu"), pProcess->GetLogonId());
  597. int item = m_ProcessList.InsertItem(m_ProcessList.GetItemCount(), ProcString, NULL);
  598. // PID
  599. ProcString.Format(TEXT("%lu"), pProcess->GetPID());
  600. m_ProcessList.SetItemText(item, WS_PROC_COL_PID, ProcString);
  601. // Image
  602. m_ProcessList.SetItemText(item, WS_PROC_COL_IMAGE, pProcess->GetImageName());
  603. m_ProcessList.SetItemData(item, (DWORD_PTR)pProcess);
  604. return item;
  605. } // end CWinStationProcessesPage::AddProcessToList
  606. /////////////////////////////////////
  607. // F'N: CWinStationProcessesPage::DisplayProcesses
  608. //
  609. void CWinStationProcessesPage::DisplayProcesses()
  610. {
  611. CWinAdminApp *pApp = (CWinAdminApp*)AfxGetApp();
  612. // Clear out the list control
  613. m_ProcessList.DeleteAllItems();
  614. CServer *pServer = m_pWinStation->GetServer();
  615. pServer->EnumerateProcesses();
  616. CObList *pProcessList = pServer->GetProcessList();
  617. pServer->LockProcessList();
  618. POSITION pos = pProcessList->GetHeadPosition();
  619. while(pos) {
  620. CProcess *pProcess = (CProcess*)pProcessList->GetNext(pos);
  621. // If this is a 'system' process and we aren't currently showing them,
  622. // go to the next process
  623. if(pProcess->IsSystemProcess() && !pApp->ShowSystemProcesses())
  624. continue;
  625. // If this user is not an Admin, don't show him someone else's processes
  626. if(!pApp->IsUserAdmin() && !pProcess->IsCurrentUsers())
  627. continue;
  628. // We only want to show process for this WinStation
  629. if(pProcess->GetLogonId() == m_pWinStation->GetLogonId()) {
  630. AddProcessToList(pProcess);
  631. }
  632. }
  633. m_ProcessList.SetItemState( 0 , LVIS_FOCUSED | LVIS_SELECTED , LVIS_FOCUSED | LVIS_SELECTED );
  634. pServer->UnlockProcessList();
  635. } // end CWinStationProcessesPage::DisplayProcesses
  636. //////////////////////////////
  637. // F'N: CWinStationProcessesPage::OnProcessItemChanged
  638. //
  639. void CWinStationProcessesPage::OnProcessItemChanged(NMHDR* pNMHDR, LRESULT* pResult)
  640. {
  641. NM_LISTVIEW *pLV = (NM_LISTVIEW*)pNMHDR;
  642. if(pLV->uNewState & LVIS_SELECTED) {
  643. CProcess *pProcess = (CProcess*)m_ProcessList.GetItemData(pLV->iItem);
  644. pProcess->SetSelected();
  645. }
  646. if(pLV->uOldState & LVIS_SELECTED && !(pLV->uNewState & LVIS_SELECTED)) {
  647. CProcess *pProcess = (CProcess*)m_ProcessList.GetItemData(pLV->iItem);
  648. pProcess->ClearSelected();
  649. }
  650. *pResult = 0;
  651. } // end CWinStationProcessesPage::OnProcessItemChanged
  652. //////////////////////////////
  653. // F'N: CWinStationProcessesPage::OnColumnClick
  654. //
  655. void CWinStationProcessesPage::OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult)
  656. {
  657. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  658. // TODO: Add your control notification handler code here
  659. // If the sort column hasn't changed, flip the ascending mode.
  660. if(m_CurrentSortColumn == pNMListView->iSubItem)
  661. m_bSortAscending = !m_bSortAscending;
  662. else // New sort column, start in ascending mode
  663. m_bSortAscending = TRUE;
  664. m_CurrentSortColumn = pNMListView->iSubItem;
  665. SortByColumn(VIEW_WINSTATION, PAGE_WS_PROCESSES, &m_ProcessList, m_CurrentSortColumn, m_bSortAscending);
  666. *pResult = 0;
  667. } // end CWinStationProcessesPage::OnColumnClick
  668. //////////////////////////////
  669. // F'N: CWinStationProcessesPage::OnContextMenu
  670. //
  671. void CWinStationProcessesPage::OnContextMenu(CWnd* pWnd, CPoint ptScreen)
  672. {
  673. // TODO: Add your message handler code here
  674. UINT flags;
  675. UINT Item;
  676. CPoint ptClient = ptScreen;
  677. ScreenToClient(&ptClient);
  678. // If we got here from the keyboard,
  679. if(ptScreen.x == -1 && ptScreen.y == -1) {
  680. UINT iCount = m_ProcessList.GetItemCount( );
  681. RECT rc;
  682. for( Item = 0 ; Item < iCount ; Item++ )
  683. {
  684. if( m_ProcessList.GetItemState( Item , LVIS_SELECTED ) == LVIS_SELECTED )
  685. {
  686. m_ProcessList.GetItemRect( Item , &rc , LVIR_ICON );
  687. ptScreen.x = rc.left;
  688. ptScreen.y = rc.bottom + 5;
  689. ClientToScreen( &ptScreen );
  690. break;
  691. }
  692. }
  693. if(ptScreen.x == -1 && ptScreen.y == -1)
  694. {
  695. return;
  696. }
  697. /*
  698. RECT rect;
  699. m_ProcessList.GetClientRect(&rect);
  700. ptScreen.x = (rect.right - rect.left) / 2;
  701. ptScreen.y = (rect.bottom - rect.top) / 2;
  702. ClientToScreen(&ptScreen);
  703. */
  704. }
  705. else {
  706. Item = m_ProcessList.HitTest(ptClient, &flags);
  707. if((Item == 0xFFFFFFFF) || !(flags & LVHT_ONITEM))
  708. return;
  709. }
  710. CMenu menu;
  711. menu.LoadMenu(IDR_PROCESS_POPUP);
  712. menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON |
  713. TPM_RIGHTBUTTON, ptScreen.x, ptScreen.y, AfxGetMainWnd());
  714. menu.DestroyMenu();
  715. } // end CServerProcessesPage::OnContextMenu
  716. void CWinStationProcessesPage::OnSetfocusWinstationProcessList(NMHDR* pNMHDR, LRESULT* pResult)
  717. {
  718. ODS( L"CWinStationProcessesPage::OnSetfocusWinstationProcessList\n");
  719. CWinAdminDoc *pDoc = (CWinAdminDoc*)GetDocument();
  720. m_ProcessList.Invalidate( );
  721. pDoc->RegisterLastFocus( PAGED_ITEM );
  722. *pResult = 0;
  723. }
  724. void CWinStationProcessesPage::OnKillFocusWinstationProcessList( NMHDR* , LRESULT* pResult)
  725. {
  726. m_ProcessList.Invalidate( );
  727. *pResult = 0;
  728. }
  729. ////////////////////////////////
  730. // MESSAGE MAP: CWinStationCachePage
  731. //
  732. IMPLEMENT_DYNCREATE(CWinStationCachePage, CFormView)
  733. BEGIN_MESSAGE_MAP(CWinStationCachePage, CFormView)
  734. //{{AFX_MSG_MAP(CWinStationCachePage)
  735. ON_WM_SIZE()
  736. ON_COMMAND(ID_HELP1,OnCommandHelp)
  737. //}}AFX_MSG_MAP
  738. END_MESSAGE_MAP()
  739. /////////////////////////////
  740. // F'N: CWinStationCachePage ctor
  741. //
  742. CWinStationCachePage::CWinStationCachePage()
  743. : CAdminPage(CWinStationCachePage::IDD)
  744. {
  745. //{{AFX_DATA_INIT(CWinStationCachePage)
  746. //}}AFX_DATA_INIT
  747. m_pWinStation = NULL;
  748. } // end CWinStationCachePage ctor
  749. /////////////////////////////
  750. // F'N: CWinStationCachePage dtor
  751. //
  752. CWinStationCachePage::~CWinStationCachePage()
  753. {
  754. } // end CWinStationCachePage dtor
  755. ////////////////////////////////////////
  756. // F'N: CWinStationCachePage::DoDataExchange
  757. //
  758. void CWinStationCachePage::DoDataExchange(CDataExchange* pDX)
  759. {
  760. CFormView::DoDataExchange(pDX);
  761. //{{AFX_DATA_MAP(CWinStationCachePage)
  762. //}}AFX_DATA_MAP
  763. } // end CWinStationCachePage::DoDataExchange
  764. #ifdef _DEBUG
  765. /////////////////////////////////////
  766. // F'N: CWinStationCachePage::AssertValid
  767. //
  768. void CWinStationCachePage::AssertValid() const
  769. {
  770. CFormView::AssertValid();
  771. } // end CWinStationCachePage::AssertValid
  772. //////////////////////////////
  773. // F'N: CWinStationCachePage::Dump
  774. //
  775. void CWinStationCachePage::Dump(CDumpContext& dc) const
  776. {
  777. CFormView::Dump(dc);
  778. } // end CWinStationCachePage::Dump
  779. #endif //_DEBUG
  780. //////////////////////////////
  781. // F'N: CWinStationCachePage::OnInitialUpdate
  782. //
  783. void CWinStationCachePage::OnInitialUpdate()
  784. {
  785. CFormView::OnInitialUpdate();
  786. } // end CWinStationCachePage::OnInitialUpdate
  787. //////////////////////////////
  788. // F'N: CWinStationCachePage::OnCommandHelp
  789. //
  790. void CWinStationCachePage::OnCommandHelp(void)
  791. {
  792. AfxGetApp()->WinHelp(CWinStationCachePage::IDD + HID_BASE_RESOURCE);
  793. } // end CWinStationCachePage::OnCommandHelp
  794. //////////////////////////////
  795. // F'N: CWinStationCachePage::OnSize
  796. //
  797. void CWinStationCachePage::OnSize(UINT nType, int cx, int cy)
  798. {
  799. RECT rect;
  800. GetClientRect(&rect);
  801. rect.top += LIST_TOP_OFFSET;
  802. // CFormView::OnSize(nType, cx, cy);
  803. } // end CWinStationCachePage::OnSize
  804. //////////////////////////////
  805. // F'N: CWinStationCachePage::Reset
  806. //
  807. void CWinStationCachePage::Reset(void *pWinStation)
  808. {
  809. m_pWinStation = (CWinStation*)pWinStation;
  810. DisplayCache();
  811. } // end CWinStationCachePage::Reset
  812. /////////////////////////////////////
  813. // F'N: CWinStationCachePage::DisplayCache
  814. //
  815. //
  816. void CWinStationCachePage::DisplayCache()
  817. {
  818. // We don't want to display info for the console
  819. // Even though this page is not shown for the console,
  820. // Reset() is still called and therefore, so is this function
  821. if(m_pWinStation->IsSystemConsole()) return;
  822. if(!m_pWinStation->AdditionalDone()) m_pWinStation->QueryAdditionalInformation();
  823. ExtWinStationInfo *pExtWinStationInfo = m_pWinStation->GetExtendedInfo();
  824. if(pExtWinStationInfo)
  825. {
  826. CString IDString;
  827. IDString.Format(IDS_CLIENT_CACHE,
  828. (pExtWinStationInfo->CacheTiny + pExtWinStationInfo->CacheLowMem) / 1024,
  829. pExtWinStationInfo->CacheTiny / 1024,
  830. pExtWinStationInfo->CacheXms / 1024,
  831. pExtWinStationInfo->CacheDASD / 1024);
  832. SetDlgItemText(IDC_WS_INFO_CACHE, IDString);
  833. // divide by 1024 to get Megabytes
  834. FLOAT DimCacheSize = (FLOAT)(pExtWinStationInfo->DimCacheSize / 1024);
  835. // If it is more than a Gigabyte, we need to divide by 1024 again
  836. if(DimCacheSize > 1024*1024) {
  837. IDString.Format(TEXT("%3.2fGB"), DimCacheSize / (1024*1024));
  838. }
  839. else if(DimCacheSize > 1024) {
  840. IDString.Format(TEXT("%3.2fMB"), DimCacheSize / 1024);
  841. }
  842. else if(DimCacheSize) {
  843. IDString.Format(TEXT("%fKB"), DimCacheSize);
  844. }
  845. else IDString.LoadString(IDS_NONE);
  846. SetDlgItemText(IDC_BITMAP_SIZE, IDString);
  847. IDString.Format(TEXT("%luK"), pExtWinStationInfo->DimBitmapMin / 1024);
  848. SetDlgItemText(IDC_BITMAP_MINIMUM, IDString);
  849. IDString.Format(TEXT("%lu"), pExtWinStationInfo->DimSignatureLevel);
  850. SetDlgItemText(IDC_BITMAP_SIG_LEVEL, IDString);
  851. }
  852. } // end CWinStationCachePage::DisplayCache