Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
5.1 KiB

  1. /*======================================================================================//
  2. | Process Control //
  3. | //
  4. |Copyright (c) 1998 Sequent Computer Systems, Incorporated. All rights reserved. //
  5. | //
  6. |File Name: BaseNode.cpp //
  7. | //
  8. |Description: Helpers for container nodes //
  9. | //
  10. |Created: Paul Skoglund 05-1999 //
  11. | //
  12. |Rev History: //
  13. | //
  14. |=======================================================================================*/
  15. #include "StdAfx.h"
  16. #include "BaseNode.h"
  17. #include "ManagementPages.h"
  18. HRESULT InsertProcessHeaders(IHeaderCtrl2* ipHeaderCtrl)
  19. {
  20. ASSERT(ipHeaderCtrl);
  21. if (!ipHeaderCtrl)
  22. return E_UNEXPECTED;
  23. ITEM_STR str;
  24. LoadStringHelper(str, IDS_PROCESS_ALIAS_HDR);
  25. VERIFY(S_OK == ipHeaderCtrl->InsertColumn( CProcessFolder::PROCESS_ALIAS_COLUMN, str, 0, PROCESS_ALIAS_COLUMN_WIDTH ));
  26. LoadStringHelper(str, IDS_IMAGE_NAME_HDR);
  27. VERIFY(S_OK == ipHeaderCtrl->InsertColumn( CProcessFolder::IMAGE_NAME_COLUMN, str, 0, IMAGE_NAME_COLUMN_WIDTH ));
  28. LoadStringHelper(str, IDS_PID_HDR);
  29. VERIFY(S_OK == ipHeaderCtrl->InsertColumn( CProcessFolder::PID_COLUMN, str, 0, PID_COLUMN_WIDTH ));
  30. LoadStringHelper(str, IDS_STATUS_HDR);
  31. VERIFY(S_OK == ipHeaderCtrl->InsertColumn( CProcessFolder::STATUS_COLUMN, str, 0, STATUS_COLUMN_WIDTH ));
  32. LoadStringHelper(str, IDS_AFFINITY_HDR);
  33. VERIFY(S_OK == ipHeaderCtrl->InsertColumn( CProcessFolder::AFFINITY_COLUMN, str, 0, AFFINITY_COLUMN_WIDTH ));
  34. LoadStringHelper(str, IDS_PRIORITY_HDR);
  35. VERIFY(S_OK == ipHeaderCtrl->InsertColumn( CProcessFolder::PRIORITY_COLUMN, str, 0, PRIORITY_COLUMN_WIDTH ));
  36. LoadStringHelper(str, IDS_JOB_OWNER_HDR);
  37. VERIFY(S_OK == ipHeaderCtrl->InsertColumn( CProcessFolder::JOB_OWNER_COLUMN, str, 0, JOB_OWNER_COLUMN_WIDTH ));
  38. LoadStringHelper(str, IDS_USER_TIME_HDR);
  39. VERIFY(S_OK == ipHeaderCtrl->InsertColumn( CProcessFolder::USER_TIME_COLUMN, str, 0, USER_TIME_COLUMN_WIDTH ));
  40. LoadStringHelper(str, IDS_KERNEL_TIME_HDR);
  41. VERIFY(S_OK == ipHeaderCtrl->InsertColumn( CProcessFolder::KERNEL_TIME_COLUMN, str, 0, KERNEL_TIME_COLUMN_WIDTH ));
  42. LoadStringHelper(str, IDS_CREATE_TIME_HDR);
  43. VERIFY(S_OK == ipHeaderCtrl->InsertColumn( CProcessFolder::CREATE_TIME_COLUMN, str, 0, CREATE_TIME_COLUMN_WIDTH ));
  44. return S_OK;
  45. }
  46. HRESULT PCProcListGetDisplayInfo(RESULTDATAITEM &ResultItem, const PCProcListItem &ref, ITEM_STR &StorageStr)
  47. {
  48. if (ResultItem.mask & RDI_IMAGE)
  49. {
  50. if (ref.lFlags & PCLFLAG_IS_DEFINED)
  51. ResultItem.nImage = PROCITEMIMAGE;
  52. else
  53. ResultItem.nImage = PROCITEMIMAGE_NODEFINITION;
  54. }
  55. if (ResultItem.mask & RDI_STR)
  56. {
  57. LPCTSTR &pstr = ResultItem.str;
  58. switch (ResultItem.nCol)
  59. {
  60. case CProcessFolder::PROCESS_ALIAS_COLUMN:
  61. pstr = ref.procName;
  62. break;
  63. case CProcessFolder::IMAGE_NAME_COLUMN:
  64. if (ref.lFlags & PCLFLAG_IS_RUNNING)
  65. pstr = ref.imageName;
  66. else
  67. pstr = _T("");
  68. break;
  69. case CProcessFolder::PID_COLUMN:
  70. if (ref.lFlags & PCLFLAG_IS_RUNNING)
  71. pstr = FormatPCUINT64(StorageStr, ref.procStats.pid);
  72. else
  73. pstr = _T("");
  74. break;
  75. case CProcessFolder::STATUS_COLUMN:
  76. if(ref.lFlags & PCLFLAG_IS_MANAGED)
  77. pstr = (TCHAR *) LoadStringHelper(StorageStr, IDS_MANAGED);
  78. else
  79. pstr = _T("");
  80. break;
  81. case CProcessFolder::AFFINITY_COLUMN:
  82. if (ref.lFlags & PCLFLAG_IS_RUNNING)
  83. pstr = FormatAffinity(StorageStr, ref.actualAffinity);
  84. else
  85. pstr = _T("");
  86. break;
  87. case CProcessFolder::PRIORITY_COLUMN:
  88. if (ref.lFlags & PCLFLAG_IS_RUNNING)
  89. pstr = FormatPriority(StorageStr, ref.actualPriority);
  90. else
  91. pstr = _T("");
  92. break;
  93. case CProcessFolder::JOB_OWNER_COLUMN:
  94. if (ref.lFlags & PCLFLAG_IS_IN_A_JOB)
  95. pstr = ref.jobName;
  96. else
  97. pstr = _T("");
  98. break;
  99. case CProcessFolder::USER_TIME_COLUMN:
  100. if (ref.lFlags & PCLFLAG_IS_RUNNING)
  101. pstr = FormatTimeToms(StorageStr, ref.procStats.TotalUserTime);
  102. else
  103. pstr = _T("");
  104. break;
  105. case CProcessFolder::KERNEL_TIME_COLUMN:
  106. if (ref.lFlags & PCLFLAG_IS_RUNNING)
  107. pstr = FormatTimeToms(StorageStr, ref.procStats.TotalKernelTime);
  108. else
  109. pstr = _T("");
  110. break;
  111. case CProcessFolder::CREATE_TIME_COLUMN:
  112. if (ref.lFlags & PCLFLAG_IS_RUNNING)
  113. pstr = FormatTime(StorageStr, ref.procStats.createTime);
  114. else
  115. pstr = _T("");
  116. break;
  117. default:
  118. ASSERT(FALSE);
  119. pstr = _T("");
  120. break;
  121. }
  122. }
  123. return S_OK;
  124. }