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.

778 lines
22 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: S M T L P S P . C P P
  7. //
  8. // Contents: The rendering of the UI for the network status monitor
  9. //
  10. // Notes:
  11. //
  12. // Author: CWill 10/06/1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "sminc.h"
  18. #include "smpsh.h"
  19. #include "smutil.h"
  20. #include "ncnetcon.h"
  21. //
  22. // External data
  23. //
  24. extern const WCHAR c_szSpace[];
  25. //
  26. // Global Data
  27. //
  28. WCHAR c_szCmdLineFlagPrefix[] = L" -";
  29. // The tool flags we can have registered
  30. //
  31. SM_TOOL_FLAGS g_asmtfMap[] =
  32. {
  33. {SCLF_CONNECTION, L"connection"},
  34. {SCLF_ADAPTER, L"adapter"},
  35. };
  36. INT c_cAsmtfMap = celems(g_asmtfMap);
  37. // The strings associated with the connection media type
  38. //
  39. WCHAR* g_pszNcmMap[] =
  40. {
  41. L"NCT_NONE",
  42. L"NCT_DIRECT",
  43. L"NCT_ISDN",
  44. L"NCT_LAN",
  45. L"NCT_PHONE",
  46. L"NCT_TUNNEL"
  47. };
  48. //+---------------------------------------------------------------------------
  49. //
  50. // Member: CPspStatusMonitorTool::CPspStatusMonitorTool
  51. //
  52. // Purpose: Creator
  53. //
  54. // Arguments: None
  55. //
  56. // Returns: Nil
  57. //
  58. CPspStatusMonitorTool::CPspStatusMonitorTool(VOID) :
  59. m_hwndToolList(NULL)
  60. {
  61. }
  62. //+---------------------------------------------------------------------------
  63. //
  64. // Member: CPspStatusMonitorTool::~CPspStatusMonitorTool
  65. //
  66. // Purpose: Destructor
  67. //
  68. // Arguments: None
  69. //
  70. // Returns: Nil
  71. //
  72. CPspStatusMonitorTool::~CPspStatusMonitorTool(VOID)
  73. {
  74. // Note : We don't want to try and destroy the objects in m_lstpsmte as
  75. // they are owned by g_ncsCentral
  76. //
  77. // Free the items we own
  78. //
  79. ::FreeCollectionAndItem(m_lstpstrCompIds);
  80. }
  81. //+---------------------------------------------------------------------------
  82. //
  83. // Member: CPspStatusMonitorTool::HrInitToolPage
  84. //
  85. // Purpose: Initialize the tools page class before the page has been
  86. // created
  87. //
  88. // Arguments: pncInit - The connection associated with this monitor
  89. //
  90. // Returns: Error code
  91. //
  92. HRESULT CPspStatusMonitorTool::HrInitToolPage(INetConnection* pncInit,
  93. const DWORD * adwHelpIDs)
  94. {
  95. // set context help ID
  96. m_adwHelpIDs = adwHelpIDs;
  97. // Find out what media type the connection is over
  98. //
  99. NETCON_PROPERTIES* pProps;
  100. HRESULT hr = pncInit->GetProperties(&pProps);
  101. if (SUCCEEDED(hr))
  102. {
  103. m_guidId = pProps->guidId;
  104. m_dwCharacter = pProps->dwCharacter;
  105. FreeNetconProperties(pProps);
  106. pProps = NULL;
  107. // Initialize m_strDeviceType
  108. hr = HrGetDeviceType(pncInit);
  109. if (S_OK != hr)
  110. {
  111. TraceError("CPspStatusMonitorTool::HrInitToolPage did not get MediaType info", hr);
  112. hr = S_OK;
  113. }
  114. // Now choose what tools should be in the list
  115. //
  116. hr = HrCreateToolList(pncInit);
  117. if (SUCCEEDED(hr))
  118. {
  119. hr = HrInitToolPageType(pncInit);
  120. }
  121. }
  122. TraceError("CPspStatusMonitorTool::HrInitToolPage",hr);
  123. return hr;
  124. }
  125. //+---------------------------------------------------------------------------
  126. //
  127. // Member: CPspStatusMonitorTool::HrCreateToolList
  128. //
  129. // Purpose: From the global list of all possible tools, select the ones
  130. // that should be shown in this monitor
  131. //
  132. // Arguments: pncInit The connection we are showing status on
  133. //
  134. // Returns: Nil
  135. //
  136. HRESULT CPspStatusMonitorTool::HrCreateToolList(INetConnection* pncInit)
  137. {
  138. HRESULT hr = S_OK;
  139. list<CStatMonToolEntry*>* plstpsmteCent = NULL;
  140. list<CStatMonToolEntry*>::iterator iterPsmte;
  141. CNetStatisticsCentral * pnsc = NULL;
  142. hr = CNetStatisticsCentral::HrGetNetStatisticsCentral(&pnsc, FALSE);
  143. if (SUCCEEDED(hr))
  144. {
  145. // Get the list of all the possible tools
  146. //
  147. plstpsmteCent = pnsc->PlstsmteRegEntries();
  148. AssertSz(plstpsmteCent, "We should have a plstpsmteCent");
  149. // Find out what tools should be in the dialog
  150. //
  151. if (plstpsmteCent->size() >0) // if at least one tool is registered
  152. {
  153. // Initialize m_lstpstrCompIds
  154. // We should only do this if some of the tools do have a component list
  155. BOOL fGetComponentList = FALSE;
  156. iterPsmte = plstpsmteCent->begin();
  157. while (!fGetComponentList && (iterPsmte != plstpsmteCent->end()))
  158. {
  159. if ((*iterPsmte)->lstpstrComponentID.size()>0)
  160. fGetComponentList = TRUE;
  161. iterPsmte++;
  162. }
  163. if (fGetComponentList)
  164. {
  165. hr = HrGetComponentList(pncInit);
  166. if (S_OK != hr)
  167. {
  168. TraceError("CPspStatusMonitorTool::HrCreateToolList did not get Component list", hr);
  169. hr = S_OK;
  170. }
  171. }
  172. iterPsmte = plstpsmteCent->begin();
  173. while (iterPsmte != plstpsmteCent->end())
  174. {
  175. // If this is a tool we should show in this dialog, add it to the
  176. // tool page's list.
  177. //
  178. if (FToolToAddToList(*iterPsmte))
  179. {
  180. // Note : There is no ownership on this list, the central
  181. // structure is responsible for destroying the tool objects
  182. //
  183. m_lstpsmte.push_back(*iterPsmte);
  184. }
  185. iterPsmte++;
  186. }
  187. }
  188. ::ReleaseObj(pnsc);
  189. }
  190. TraceError("CPspStatusMonitorTool::HrCreateToolList",hr);
  191. return hr;
  192. }
  193. //+---------------------------------------------------------------------------
  194. //
  195. // Member: CPspStatusMonitorTool::FToolToAddToList
  196. //
  197. // Purpose: Determines wheither a tool should validly be added to the
  198. // tool list for this particular monitor
  199. //
  200. // Arguments: psmteTest - The tool entry that is to be tested to see if it
  201. // matches the criteria to be added to the list
  202. //
  203. // Returns: TRUE if the tool should be added, FALSE if it should not
  204. //
  205. BOOL CPspStatusMonitorTool::FToolToAddToList(CStatMonToolEntry* psmteTest)
  206. {
  207. BOOL fRet = TRUE;
  208. AssertSz(psmteTest, "We should have a psmteTest");
  209. // 1) Check connection type
  210. AssertSz(((NCM_NONE == 0)
  211. && (NCM_DIRECT == NCM_NONE + 1)
  212. && (NCM_ISDN == NCM_DIRECT + 1)
  213. && (NCM_LAN == NCM_ISDN + 1)
  214. && (NCM_PHONE == NCM_LAN + 1)
  215. && (NCM_TUNNEL == NCM_PHONE + 1)),
  216. "Someone has been mucking with NETCON_MEDIATYPE");
  217. // See if this tools should only be on certain connections. If no
  218. // specific connection is listed, the tool is valid for all
  219. //
  220. if (!(psmteTest->lstpstrConnectionType).empty())
  221. {
  222. fRet = ::FIsStringInList(&(psmteTest->lstpstrConnectionType),
  223. g_pszNcmMap[m_ncmType]);
  224. }
  225. // 2) Check device type
  226. //
  227. if ((fRet) && !(psmteTest->lstpstrConnectionType).empty())
  228. {
  229. fRet = ::FIsStringInList(&(psmteTest->lstpstrMediaType),
  230. m_strDeviceType.c_str());
  231. }
  232. // 3) Check component list
  233. //
  234. if ((fRet) && !(psmteTest->lstpstrComponentID).empty())
  235. {
  236. BOOL fValid = FALSE;
  237. list<tstring*>::iterator iterLstpstr;
  238. iterLstpstr = m_lstpstrCompIds.begin();
  239. while ((!fValid)
  240. && (iterLstpstr != m_lstpstrCompIds.end()))
  241. {
  242. // See if the component is also on the tools component list
  243. //
  244. fValid = ::FIsStringInList(&(psmteTest->lstpstrComponentID),
  245. (*iterLstpstr)->c_str());
  246. iterLstpstr++;
  247. }
  248. // Give back the result
  249. //
  250. fRet = fValid;
  251. }
  252. return fRet;
  253. }
  254. //+---------------------------------------------------------------------------
  255. //
  256. // Member: CPspStatusMonitorTool::OnInitDialog
  257. //
  258. // Purpose: Do the initialization required when the page has just been created
  259. //
  260. // Arguments: Standard window messsage parameters
  261. //
  262. // Returns: Standard window message return value
  263. //
  264. LRESULT CPspStatusMonitorTool::OnInitDialog(UINT uMsg, WPARAM wParam,
  265. LPARAM lParam, BOOL& bHandled)
  266. {
  267. HRESULT hr = S_OK;
  268. LVCOLUMN lvcTemp = { 0 };
  269. RECT rectToolList;
  270. m_hwndToolList = GetDlgItem(IDC_LST_SM_TOOLS);
  271. AssertSz(m_hwndToolList, "We don't have a tool list window");
  272. //
  273. // Set up the column
  274. //
  275. lvcTemp.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM;
  276. lvcTemp.fmt = LVCFMT_LEFT;
  277. // Set the width of the column to the width of the window (minus a bit
  278. // for the borders)
  279. //
  280. ::GetWindowRect(m_hwndToolList, &rectToolList);
  281. lvcTemp.cx = (rectToolList.right - rectToolList.left - 4);
  282. // lvcTemp.pszText = NULL;
  283. // lvcTemp.cchTextMax = 0;
  284. // lvcTemp.iSubItem = 0;
  285. // lvcTemp.iImage = 0;
  286. // lvcTemp.iOrder = 0;
  287. // Add the column to the list
  288. //
  289. if (-1 == ListView_InsertColumn(m_hwndToolList, 0, &lvcTemp))
  290. {
  291. hr = ::HrFromLastWin32Error();
  292. }
  293. // Fill out the dialog
  294. //
  295. if (SUCCEEDED(hr))
  296. {
  297. hr = HrFillToolList();
  298. }
  299. TraceError("CPspStatusMonitorTool::OnInitDialog", hr);
  300. return 0;
  301. }
  302. //+---------------------------------------------------------------------------
  303. //
  304. // Member: CPspStatusMonitorTool::HrFillToolList
  305. //
  306. // Purpose: Fills the tool list with correct items
  307. //
  308. // Arguments: None
  309. //
  310. // Returns: Error code
  311. //
  312. HRESULT CPspStatusMonitorTool::HrFillToolList(VOID)
  313. {
  314. HRESULT hr = S_OK;
  315. INT iItem = 0;
  316. list<CStatMonToolEntry*>::iterator iterSmte;
  317. // Tell the control how many items are being inserted so it can do a
  318. // better job allocating internal structures.
  319. ListView_SetItemCount(m_hwndToolList, m_lstpsmte.size());
  320. //
  321. // Fill in the combo box with subnet entries.
  322. //
  323. iterSmte = m_lstpsmte.begin();
  324. while ((SUCCEEDED(hr)) && (iterSmte != m_lstpsmte.end()))
  325. {
  326. // Save some indirections
  327. hr = HrAddOneEntryToToolList(*iterSmte, iItem);
  328. // Move on the the next person.
  329. iterSmte++;
  330. iItem++;
  331. }
  332. // Selete the first item
  333. if (SUCCEEDED(hr))
  334. {
  335. ListView_SetItemState(m_hwndToolList, 0, LVIS_FOCUSED, LVIS_FOCUSED);
  336. }
  337. // Enable/Disable the "Open" button based on whether tools are present
  338. //
  339. ::EnableWindow(GetDlgItem(IDC_BTN_SM_TOOLS_OPEN), (0 != iItem));
  340. TraceError("CPspStatusMonitorTool::HrFillToolList", hr);
  341. return hr;
  342. }
  343. //+---------------------------------------------------------------------------
  344. //
  345. // Member: CPspStatusMonitorTool::HrAddOneEntryToToolList
  346. //
  347. // Purpose: Take a tool associated with the connection and put it
  348. // in the listview control
  349. //
  350. // Arguments: psmteAdd - The tool to add
  351. // iItem - Where to put in in the list control
  352. //
  353. // Returns: Error code.
  354. //
  355. HRESULT CPspStatusMonitorTool::HrAddOneEntryToToolList(
  356. CStatMonToolEntry* psmteAdd, INT iItem)
  357. {
  358. HRESULT hr = S_OK;
  359. LVITEM lviTemp;
  360. lviTemp.mask = LVIF_TEXT | LVIF_PARAM;
  361. lviTemp.iItem = iItem;
  362. lviTemp.iSubItem = 0;
  363. lviTemp.state = 0;
  364. lviTemp.stateMask = 0;
  365. lviTemp.pszText = const_cast<PWSTR>(
  366. psmteAdd->strDisplayName.c_str());
  367. lviTemp.cchTextMax = psmteAdd->strDisplayName.length();
  368. lviTemp.iImage = -1;
  369. lviTemp.lParam = reinterpret_cast<LPARAM>(psmteAdd);
  370. lviTemp.iIndent = 0;
  371. //$ REVIEW : CWill : 10/16/97 : Return values
  372. // Set up the item
  373. //
  374. ListView_InsertItem(m_hwndToolList, &lviTemp);
  375. TraceError("CPspStatusMonitorTool::HrAddOneEntryToToolList", hr);
  376. return hr;
  377. }
  378. //+---------------------------------------------------------------------------
  379. //
  380. // Member: CPspStatusMonitorTool::OnContextMenu
  381. //
  382. // Purpose: When right click a control, bring up help
  383. //
  384. // Arguments: Standard command parameters
  385. //
  386. // Returns: Standard return
  387. //
  388. LRESULT
  389. CPspStatusMonitorTool::OnContextMenu(UINT uMsg,
  390. WPARAM wParam,
  391. LPARAM lParam,
  392. BOOL& fHandled)
  393. {
  394. if (m_adwHelpIDs != NULL)
  395. {
  396. ::WinHelp(m_hWnd,
  397. c_szNetCfgHelpFile,
  398. HELP_CONTEXTMENU,
  399. (ULONG_PTR)m_adwHelpIDs);
  400. }
  401. return 0;
  402. }
  403. //+---------------------------------------------------------------------------
  404. //
  405. // Member: CPspStatusMonitorTool::OnHelp
  406. //
  407. // Purpose: When drag context help icon over a control, bring up help
  408. //
  409. // Arguments: Standard command parameters
  410. //
  411. // Returns: Standard return
  412. //
  413. LRESULT
  414. CPspStatusMonitorTool::OnHelp(UINT uMsg,
  415. WPARAM wParam,
  416. LPARAM lParam,
  417. BOOL& fHandled)
  418. {
  419. LPHELPINFO lphi = reinterpret_cast<LPHELPINFO>(lParam);
  420. Assert(lphi);
  421. if ((m_adwHelpIDs != NULL) && (HELPINFO_WINDOW == lphi->iContextType))
  422. {
  423. ::WinHelp(static_cast<HWND>(lphi->hItemHandle),
  424. c_szNetCfgHelpFile,
  425. HELP_WM_HELP,
  426. (ULONG_PTR)m_adwHelpIDs);
  427. }
  428. return 0;
  429. }
  430. //+---------------------------------------------------------------------------
  431. //
  432. // Member: CPspStatusMonitorTool::OnDestroy
  433. //
  434. // Purpose: Clean up the dialog before the window goes away
  435. //
  436. // Arguments: Standard window messsage parameters
  437. //
  438. // Returns: Standard window message return value
  439. //
  440. LRESULT CPspStatusMonitorTool::OnDestroy(UINT uMsg, WPARAM wParam,
  441. LPARAM lParam, BOOL& bHandled)
  442. {
  443. // Clean out the old items when the dialog closes
  444. //
  445. ::FreeCollectionAndItem(m_lstpstrCompIds);
  446. // Don't free the entries, because we don't own them
  447. //
  448. m_lstpsmte.erase(m_lstpsmte.begin(), m_lstpsmte.end());
  449. return 0;
  450. }
  451. //+---------------------------------------------------------------------------
  452. //
  453. // Member: CPspStatusMonitorTool::OnToolOpen
  454. //
  455. // Purpose: Open the tool that is selected
  456. //
  457. // Arguments: Standard window message
  458. //
  459. // Returns: Standard return.
  460. //
  461. LRESULT CPspStatusMonitorTool::OnToolOpen(WORD wNotifyCode, WORD wID,
  462. HWND hWndCtl, BOOL& fHandled)
  463. {
  464. HRESULT hr = S_OK;
  465. switch (wNotifyCode)
  466. {
  467. case BN_CLICKED:
  468. hr = HrLaunchTool();
  469. break;
  470. }
  471. return 0;
  472. }
  473. //+---------------------------------------------------------------------------
  474. //
  475. // Member: CPspStatusMonitorTool::OnItemActivate
  476. //
  477. // Purpose: When an item is acivated in the tool list, launch the tool
  478. //
  479. // Arguments: Standard notification messages
  480. //
  481. // Returns: Stadard return
  482. //
  483. LRESULT CPspStatusMonitorTool::OnItemActivate(INT idCtrl, LPNMHDR pnmh,
  484. BOOL& bHandled)
  485. {
  486. // Launch the tool
  487. //
  488. HRESULT hr = HrLaunchTool();
  489. return 0;
  490. }
  491. //+---------------------------------------------------------------------------
  492. //
  493. // Member: CPspStatusMonitorTool::OnItemChanged
  494. //
  495. // Purpose: When one of the items change, see if it is the focus and set
  496. // the description accordingly
  497. //
  498. // Arguments: Standard notification messages
  499. //
  500. // Returns: Stadard return
  501. //
  502. LRESULT CPspStatusMonitorTool::OnItemChanged(INT idCtrl, LPNMHDR pnmh,
  503. BOOL& bHandled)
  504. {
  505. HRESULT hr = S_OK;
  506. NMLISTVIEW* pnmlvChange = NULL;
  507. // Cast to the right header
  508. //
  509. pnmlvChange = reinterpret_cast<NMLISTVIEW*>(pnmh);
  510. // If the item now has the focus, display its description
  511. //
  512. if (LVIS_FOCUSED & pnmlvChange->uNewState)
  513. {
  514. CStatMonToolEntry* psmteItem = NULL;
  515. psmteItem = reinterpret_cast<CStatMonToolEntry*>(pnmlvChange->lParam);
  516. AssertSz(psmteItem, "We haven't got any data in changing item");
  517. // Set the manufacturer
  518. SetDlgItemText(IDC_TXT_SM_TOOL_MAN,
  519. psmteItem->strManufacturer.c_str());
  520. // Set the commandline
  521. //
  522. tstring strCommandLineAndFlags = psmteItem->strCommandLine;
  523. tstring strFlags;
  524. hr = HrAddAllCommandLineFlags(&strFlags, psmteItem);
  525. if (SUCCEEDED(hr))
  526. {
  527. strCommandLineAndFlags.append(c_szSpace);;
  528. strCommandLineAndFlags += strFlags;
  529. }
  530. SetDlgItemText(IDC_TXT_SM_TOOL_COMMAND,
  531. strCommandLineAndFlags.c_str());
  532. // Show the description
  533. SetDlgItemText( IDC_TXT_SM_TOOL_DESC,
  534. psmteItem->strDescription.c_str());
  535. }
  536. TraceError("CPspStatusMonitorTool::OnItemChanged", hr);
  537. return 0;
  538. }
  539. //+---------------------------------------------------------------------------
  540. //
  541. // Member: CPspStatusMonitorTool::HrLaunchTool
  542. //
  543. // Purpose: Launches the tool that is selected in the tools list
  544. //
  545. // Arguments: None
  546. //
  547. // Returns: Error code
  548. //
  549. HRESULT CPspStatusMonitorTool::HrLaunchTool(VOID)
  550. {
  551. HRESULT hr = S_OK;
  552. // We can only launch one tool at a time
  553. //
  554. if (1 == ListView_GetSelectedCount(m_hwndToolList))
  555. {
  556. INT iSelect = -1;
  557. LV_ITEM lviTemp = { 0 };
  558. CStatMonToolEntry* psmteSelection = NULL;
  559. tstring strFlags;
  560. //
  561. // Extract the data associated with the selection.
  562. //
  563. iSelect = ListView_GetSelectionMark(m_hwndToolList);
  564. AssertSz((0 <= iSelect), "I thought we were supposed to have a selection");
  565. // Set up the data item to get back to the parameter
  566. //
  567. lviTemp.iItem = iSelect;
  568. lviTemp.mask = LVIF_PARAM;
  569. ListView_GetItem(m_hwndToolList, &lviTemp);
  570. psmteSelection = reinterpret_cast<CStatMonToolEntry*>(lviTemp.lParam);
  571. AssertSz(psmteSelection, "We haven't got any data in a selection");
  572. // Get all the flags
  573. //
  574. hr = HrAddAllCommandLineFlags(&strFlags, psmteSelection);
  575. if (SUCCEEDED(hr))
  576. {
  577. SHELLEXECUTEINFO seiTemp = { 0 };
  578. //
  579. // Fill in the data structure
  580. //
  581. seiTemp.cbSize = sizeof(SHELLEXECUTEINFO);
  582. seiTemp.fMask = SEE_MASK_DOENVSUBST;
  583. seiTemp.hwnd = NULL;
  584. seiTemp.lpVerb = NULL;
  585. seiTemp.lpFile = psmteSelection->strCommandLine.c_str();
  586. seiTemp.lpParameters = strFlags.c_str();
  587. seiTemp.lpDirectory = NULL;
  588. seiTemp.nShow = SW_SHOW;
  589. seiTemp.hInstApp = NULL;
  590. seiTemp.hProcess = NULL;
  591. // Launch the tool
  592. //
  593. if (!::ShellExecuteEx(&seiTemp))
  594. {
  595. hr = ::HrFromLastWin32Error();
  596. }
  597. }
  598. }
  599. TraceError("CPspStatusMonitorTool::HrLaunchTool", hr);
  600. return hr;
  601. }
  602. //+---------------------------------------------------------------------------
  603. //
  604. // Member: CPspStatusMonitorTool::HrAddAllCommandLineFlags
  605. //
  606. // Purpose: Adds the flags for this selection to the command line for the
  607. // tool being launched. Include the private and the connection
  608. // specific flags.
  609. //
  610. // Arguments: pstrFlags - The command line that the flags have to be
  611. // appended to
  612. // psmteSel - The tool entry associated with this selection
  613. //
  614. // Returns: Error code
  615. //
  616. HRESULT CPspStatusMonitorTool::HrAddAllCommandLineFlags(tstring* pstrFlags,
  617. CStatMonToolEntry* psmteSel)
  618. {
  619. HRESULT hr = S_OK;
  620. //$ REVIEW : CWill : 02/24/98 : Will there be default command line flags
  621. //$ REVIEW : that the user will want to have to launch the tool? If so,
  622. //$ REIVEW : an entry should be added to as a REG_SZ to the tools subkey.
  623. // Add both the commom and the conneciton specific command line flags
  624. //
  625. hr = HrAddCommonCommandLineFlags(pstrFlags, psmteSel);
  626. if (SUCCEEDED(hr))
  627. {
  628. hr = HrAddCommandLineFlags(pstrFlags, psmteSel);
  629. }
  630. TraceError("CPspStatusMonitorTool::HrAddCommandLineFlags", hr);
  631. return hr;
  632. }
  633. //+---------------------------------------------------------------------------
  634. //
  635. // Member: CPspStatusMonitorTool::HrAddCommonCommandLineFlags
  636. //
  637. // Purpose: Adds the flags that all types of connections share.
  638. //
  639. // Arguments: pstrFlags - The command line that the flags have to be
  640. // appended to
  641. // psmteSel - The tool entry associated with this selection
  642. //
  643. // Returns: Error code
  644. //
  645. HRESULT CPspStatusMonitorTool::HrAddCommonCommandLineFlags(tstring* pstrFlags,
  646. CStatMonToolEntry* psmteSel)
  647. {
  648. HRESULT hr = S_OK;
  649. DWORD dwFlags = 0x0;
  650. // Same some indirections
  651. //
  652. dwFlags = psmteSel->dwFlags;
  653. //
  654. // Check what flags are asked for and provide them if we can
  655. //
  656. if (SCLF_CONNECTION & dwFlags)
  657. {
  658. WCHAR achConnGuid[c_cchGuidWithTerm];
  659. pstrFlags->append(c_szCmdLineFlagPrefix);
  660. pstrFlags->append(g_asmtfMap[STFI_CONNECTION].pszFlag);
  661. pstrFlags->append(c_szSpace);
  662. // Make a GUID string
  663. //
  664. ::StringFromGUID2 (m_guidId, achConnGuid,
  665. c_cchGuidWithTerm);
  666. pstrFlags->append(achConnGuid);
  667. }
  668. TraceError("CPspStatusMonitorTool::HrAddCommandLineFlags", hr);
  669. return hr;
  670. }