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.

270 lines
7.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // TaskMan - NT TaskManager
  4. // Copyright (C) Microsoft
  5. //
  6. // File: TaskMan.H
  7. //
  8. // History: Nov-10-95 DavePl Created
  9. // Jun-30-98 Alhen Adding code for TerminalServer
  10. //
  11. //--------------------------------------------------------------------------
  12. #define WM_FINDPROC (WM_USER + 1)
  13. #define PM_NOTIFYWAITING (WM_USER + 2)
  14. #define PM_QUITTRAYTHREAD (WM_USER + 3)
  15. #define PM_INITIALIZEICONS (WM_USER + 4)
  16. extern DWORD g_idTrayThread;
  17. extern LONG g_minWidth;
  18. extern LONG g_minHeight;
  19. extern BOOL g_fIsTSEnabled;
  20. extern BOOL g_fIsSingleUserTS;
  21. extern BOOL g_fIsTSServer;
  22. extern DWORD g_dwMySessionId;
  23. extern int g_nPages;
  24. DWORD TrayThreadMessageLoop(LPVOID);
  25. #define TASK_PAGE 0
  26. #define PROC_PAGE 1
  27. #define PERF_PAGE 2
  28. #define NET_PAGE 3
  29. #define USER_PAGE 4
  30. #define NUM_PAGES 5
  31. #define MIN_DLG_SIZE_X 203
  32. #define MIN_DLG_SIZE_Y 224
  33. #define DLG_SCALE_X 4
  34. #define DLG_SCALE_Y 8
  35. //
  36. // Process Page Column ID enumeration
  37. //
  38. typedef enum COLUMNID
  39. {
  40. COL_IMAGENAME = 0,
  41. COL_PID = 1,
  42. // _HYDRA
  43. COL_USERNAME = 2,
  44. COL_SESSIONID = 3,
  45. //
  46. COL_CPU = 4,
  47. COL_CPUTIME = 5,
  48. COL_MEMUSAGE = 6,
  49. COL_MEMPEAK = 7,
  50. COL_MEMUSAGEDIFF = 8,
  51. COL_PAGEFAULTS = 9,
  52. COL_PAGEFAULTSDIFF = 10,
  53. COL_COMMITCHARGE = 11,
  54. COL_PAGEDPOOL = 12,
  55. COL_NONPAGEDPOOL = 13,
  56. COL_BASEPRIORITY = 14,
  57. COL_HANDLECOUNT = 15,
  58. COL_THREADCOUNT = 16,
  59. COL_USEROBJECTS = 17,
  60. COL_GDIOBJECTS = 18,
  61. COL_READOPERCOUNT = 19,
  62. COL_WRITEOPERCOUNT = 20,
  63. COL_OTHEROPERCOUNT = 21,
  64. COL_READXFERCOUNT = 22,
  65. COL_WRITEXFERCOUNT = 23,
  66. COL_OTHERXFERCOUNT = 24
  67. };
  68. typedef enum NETCOLUMNID
  69. {
  70. COL_ADAPTERNAME = 0,
  71. COL_ADAPTERDESC = 1,
  72. COL_NETWORKUTIL = 2,
  73. COL_LINKSPEED = 3,
  74. COL_STATE = 4,
  75. COL_BYTESSENTTHRU = 5,
  76. COL_BYTESRECTHRU = 6,
  77. COL_BYTESTOTALTHRU = 7,
  78. COL_BYTESSENT = 8,
  79. COL_BYTESREC = 9,
  80. COL_BYTESTOTAL = 10,
  81. COL_BYTESSENTPERINTER = 11,
  82. COL_BYTESRECPERINTER = 12,
  83. COL_BYTESTOTALPERINTER = 13,
  84. COL_UNICASTSSSENT = 14,
  85. COL_UNICASTSREC = 15,
  86. COL_UNICASTSTOTAL = 16,
  87. COL_UNICASTSSENTPERINTER = 17,
  88. COL_UNICASTSRECPERINTER = 18,
  89. COL_UNICASTSTOTALPERINTER = 19,
  90. COL_NONUNICASTSSSENT = 20,
  91. COL_NONUNICASTSREC = 21,
  92. COL_NONUNICASTSTOTAL = 22,
  93. COL_NONUNICASTSSENTPERINTER = 23,
  94. COL_NONUNICASTSRECPERINTER = 24,
  95. COL_NONUNICASTSTOTALPERINTER = 25
  96. };
  97. #define MAX_COLUMN 24
  98. #define NUM_COLUMN (MAX_COLUMN + 1)
  99. #define NUM_NETCOLUMN 26
  100. #define IDS_FIRSTCOL 20001 // 20000 is first column name ID in rc file
  101. // GetLastHRESULT
  102. //
  103. // Little wrapper func that returns the GetLastError value as an HRESULT
  104. inline HRESULT GetLastHRESULT()
  105. {
  106. return HRESULT_FROM_WIN32(GetLastError());
  107. }
  108. // Possible values for the viewmode
  109. typedef enum
  110. {
  111. VM_LARGEICON,
  112. VM_SMALLICON,
  113. VM_DETAILS,
  114. VM_INVALID
  115. } VIEWMODE;
  116. #define VM_FIRST IDM_LARGEICONS
  117. #define VM_LAST IDM_DETAILS
  118. // Possible values for the cpu history mode
  119. typedef enum
  120. {
  121. CM_SUM,
  122. CM_PANES
  123. } CPUHISTMODE;
  124. #define CM_FIRST IDM_ALLCPUS
  125. #define CM_LAST IDM_MULTIGRAPH
  126. // Possible values for the update speed option
  127. typedef enum
  128. {
  129. US_HIGH,
  130. US_NORMAL,
  131. US_LOW,
  132. US_PAUSED
  133. } UPDATESPEED;
  134. #define US_FIRST IDM_HIGH
  135. #define US_LAST IDM_PAUSED
  136. // PtrToFns for RPC calls
  137. typedef BOOLEAN ( WINAPI *pfnWinStationGetProcessSid )( HANDLE hServer, DWORD ProcessId , FILETIME ProcessStartTime , PBYTE pProcessUserSid , PDWORD dwSidSize );
  138. typedef void ( WINAPI *pfnCachedGetUserFromSid )( PSID pSid , PWCHAR pUserName , PULONG cbUserName );
  139. typedef BOOLEAN (WINAPI *pfnWinStationTerminateProcess)( HANDLE hServer, ULONG ProcessId, ULONG ExitCode);
  140. typedef BOOLEAN (WINAPI *pfnWinStationDisconnect) ( HANDLE hServer, ULONG SessionId, BOOL bWait );
  141. extern pfnWinStationGetProcessSid gpfnWinStationGetProcessSid;
  142. extern pfnCachedGetUserFromSid gpfnCachedGetUserFromSid;
  143. // COptions
  144. //
  145. // App's persistent state across sessions, saved in the registry
  146. class COptions
  147. {
  148. public:
  149. DWORD m_cbSize;
  150. DWORD m_dwTimerInterval;
  151. VIEWMODE m_vmViewMode;
  152. CPUHISTMODE m_cmHistMode;
  153. UPDATESPEED m_usUpdateSpeed;
  154. RECT m_rcWindow;
  155. INT m_iCurrentPage;
  156. NETCOLUMNID m_ActiveNetCol[NUM_NETCOLUMN + 1];
  157. SHORT m_NetColumnWidths[NUM_NETCOLUMN + 1];
  158. INT m_NetColumnPositions[NUM_NETCOLUMN + 1];
  159. BOOL m_bAutoSize;
  160. BOOL m_bGraphBytesSent;
  161. BOOL m_bGraphBytesReceived;
  162. BOOL m_bGraphBytesTotal;
  163. BOOL m_bNetShowAll;
  164. BOOL m_bShowScale;
  165. BOOL m_bTabAlwaysActive;
  166. COLUMNID m_ActiveProcCol[NUM_COLUMN + 1];
  167. INT m_ColumnWidths[NUM_COLUMN + 1];
  168. INT m_ColumnPositions[NUM_COLUMN + 1];
  169. BOOL m_fMinimizeOnUse : 1;
  170. BOOL m_fConfirmations : 1;
  171. BOOL m_fAlwaysOnTop : 1;
  172. BOOL m_fKernelTimes : 1;
  173. BOOL m_fNoTitle : 1;
  174. BOOL m_fHideWhenMin : 1;
  175. BOOL m_fShow16Bit : 1;
  176. BOOL m_fShowDomainNames : 1;
  177. BOOL bUnused;
  178. BOOL bUnused2;
  179. BOOL m_bShowAllProcess;
  180. HRESULT Load();
  181. HRESULT Save();
  182. void SetDefaultValues();
  183. COptions()
  184. {
  185. SetDefaultValues();
  186. }
  187. };
  188. // CTrayNotification
  189. //
  190. // Class to encapsulate all of the info needed to do a tray notification
  191. class CTrayNotification
  192. {
  193. private:
  194. CTrayNotification(void); // make the constructor private to prevent access
  195. public:
  196. CTrayNotification(HWND hWnd,
  197. UINT uCallbackMessage,
  198. DWORD Message,
  199. HICON hIcon,
  200. LPTSTR pszTip)
  201. {
  202. m_hWnd = hWnd;
  203. m_uCallbackMessage = uCallbackMessage;
  204. m_Message = Message;
  205. m_hIcon = hIcon;
  206. if (pszTip)
  207. lstrcpyn(m_szTip, pszTip, ARRAYSIZE(m_szTip));
  208. else
  209. m_szTip[0] = TEXT('\0');
  210. }
  211. HWND m_hWnd;
  212. UINT m_uCallbackMessage;
  213. DWORD m_Message;
  214. HICON m_hIcon;
  215. TCHAR m_szTip[MAX_PATH];
  216. };
  217. void AdjustMenuBar(HMENU hMenu);
  218. void SubclassListView(HWND hwnd);
  219. int Compare64(unsigned __int64 First, unsigned __int64 Second);