mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
Removed obsolete cpp modules ready for new imports.
svn path=/trunk/; revision=3484
This commit is contained in:
parent
a0797d5f25
commit
ef39f0a5aa
24 changed files with 0 additions and 7740 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,50 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* applicationpage.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __APPLICATIONPAGE_H
|
|
||||||
#define __APPLICATIONPAGE_H
|
|
||||||
|
|
||||||
extern HWND hApplicationPage; // Application List Property Page
|
|
||||||
|
|
||||||
extern HWND hApplicationPageListCtrl; // Application ListCtrl Window
|
|
||||||
extern HWND hApplicationPageEndTaskButton; // Application End Task button
|
|
||||||
extern HWND hApplicationPageSwitchToButton; // Application Switch To button
|
|
||||||
extern HWND hApplicationPageNewTaskButton; // Application New Task button
|
|
||||||
|
|
||||||
LRESULT CALLBACK ApplicationPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
|
||||||
void RefreshApplicationPage(void);
|
|
||||||
void UpdateApplicationListControlViewSetting(void);
|
|
||||||
|
|
||||||
void ApplicationPage_OnViewLargeIcons(void);
|
|
||||||
void ApplicationPage_OnViewSmallIcons(void);
|
|
||||||
void ApplicationPage_OnViewDetails(void);
|
|
||||||
void ApplicationPage_OnWindowsTileHorizontally(void);
|
|
||||||
void ApplicationPage_OnWindowsTileVertically(void);
|
|
||||||
void ApplicationPage_OnWindowsMinimize(void);
|
|
||||||
void ApplicationPage_OnWindowsMaximize(void);
|
|
||||||
void ApplicationPage_OnWindowsCascade(void);
|
|
||||||
void ApplicationPage_OnWindowsBringToFront(void);
|
|
||||||
void ApplicationPage_OnSwitchTo(void);
|
|
||||||
void ApplicationPage_OnEndTask(void);
|
|
||||||
void ApplicationPage_OnGotoProcess(void);
|
|
||||||
|
|
||||||
#endif // __APPLICATIONPAGE_H
|
|
|
@ -1,712 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* GraphCtrl.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "math.h"
|
|
||||||
#include "GraphCtrl.h"
|
|
||||||
#include "TaskMgr.h"
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#define new DEBUG_NEW
|
|
||||||
#undef THIS_FILE
|
|
||||||
static char THIS_FILE[] = __FILE__;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
LONG OldGraphCtrlWndProc;
|
|
||||||
|
|
||||||
|
|
||||||
TGraphCtrl::TGraphCtrl() :
|
|
||||||
m_hWnd(0),
|
|
||||||
m_hParentWnd(0),
|
|
||||||
m_dcGrid(0),
|
|
||||||
m_dcPlot(0),
|
|
||||||
m_bitmapOldGrid(0),
|
|
||||||
m_bitmapOldPlot(0),
|
|
||||||
m_bitmapGrid(0),
|
|
||||||
m_bitmapPlot(0),
|
|
||||||
m_brushBack(0)
|
|
||||||
{
|
|
||||||
//RECT m_rectClient;
|
|
||||||
//RECT m_rectPlot;
|
|
||||||
m_penPlot[0] = 0;
|
|
||||||
m_penPlot[1] = 0;
|
|
||||||
m_penPlot[2] = 0;
|
|
||||||
m_penPlot[3] = 0;
|
|
||||||
|
|
||||||
// since plotting is based on a LineTo for each new point
|
|
||||||
// we need a starting point (i.e. a "previous" point)
|
|
||||||
// use 0.0 as the default first point.
|
|
||||||
// these are public member variables, and can be changed outside
|
|
||||||
// (after construction). Therefore m_perviousPosition could be set to
|
|
||||||
// a more appropriate value prior to the first call to SetPosition.
|
|
||||||
m_dPreviousPosition[0] = 0.0;
|
|
||||||
m_dPreviousPosition[1] = 0.0;
|
|
||||||
m_dPreviousPosition[2] = 0.0;
|
|
||||||
m_dPreviousPosition[3] = 0.0;
|
|
||||||
|
|
||||||
// public variable for the number of decimal places on the y axis
|
|
||||||
m_nYDecimals = 3;
|
|
||||||
|
|
||||||
// set some initial values for the scaling until "SetRange" is called.
|
|
||||||
// these are protected varaibles and must be set with SetRange
|
|
||||||
// in order to ensure that m_dRange is updated accordingly
|
|
||||||
// m_dLowerLimit = -10.0;
|
|
||||||
// m_dUpperLimit = 10.0;
|
|
||||||
m_dLowerLimit = 0.0;
|
|
||||||
m_dUpperLimit = 100.0;
|
|
||||||
m_dRange = m_dUpperLimit - m_dLowerLimit; // protected member variable
|
|
||||||
|
|
||||||
// m_nShiftPixels determines how much the plot shifts (in terms of pixels)
|
|
||||||
// with the addition of a new data point
|
|
||||||
m_nShiftPixels = 4;
|
|
||||||
m_nHalfShiftPixels = m_nShiftPixels/2; // protected
|
|
||||||
m_nPlotShiftPixels = m_nShiftPixels + m_nHalfShiftPixels; // protected
|
|
||||||
|
|
||||||
// background, grid and data colors
|
|
||||||
// these are public variables and can be set directly
|
|
||||||
m_crBackColor = RGB( 0, 0, 0); // see also SetBackgroundColor
|
|
||||||
m_crGridColor = RGB( 0, 255, 255); // see also SetGridColor
|
|
||||||
m_crPlotColor[0] = RGB(255, 255, 255); // see also SetPlotColor
|
|
||||||
m_crPlotColor[1] = RGB(100, 255, 255); // see also SetPlotColor
|
|
||||||
m_crPlotColor[2] = RGB(255, 100, 255); // see also SetPlotColor
|
|
||||||
m_crPlotColor[3] = RGB(255, 255, 100); // see also SetPlotColor
|
|
||||||
|
|
||||||
// protected variables
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < MAX_PLOTS; i++) {
|
|
||||||
m_penPlot[i] = CreatePen(PS_SOLID, 0, m_crPlotColor[i]);
|
|
||||||
}
|
|
||||||
m_brushBack = CreateSolidBrush(m_crBackColor);
|
|
||||||
|
|
||||||
// public member variables, can be set directly
|
|
||||||
strcpy(m_strXUnitsString, "Samples"); // can also be set with SetXUnits
|
|
||||||
strcpy(m_strYUnitsString, "Y units"); // can also be set with SetYUnits
|
|
||||||
|
|
||||||
// protected bitmaps to restore the memory DC's
|
|
||||||
m_bitmapOldGrid = NULL;
|
|
||||||
m_bitmapOldPlot = NULL;
|
|
||||||
#if 0
|
|
||||||
for (i = 0; i < MAX_CTRLS; i++) {
|
|
||||||
if (pCtrlArray[i] == 0) {
|
|
||||||
pCtrlArray[i] = this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
TGraphCtrl::~TGraphCtrl()
|
|
||||||
{
|
|
||||||
// just to be picky restore the bitmaps for the two memory dc's
|
|
||||||
// (these dc's are being destroyed so there shouldn't be any leaks)
|
|
||||||
if (m_bitmapOldGrid != NULL) SelectObject(m_dcGrid, m_bitmapOldGrid);
|
|
||||||
if (m_bitmapOldPlot != NULL) SelectObject(m_dcPlot, m_bitmapOldPlot);
|
|
||||||
if (m_bitmapGrid != NULL) DeleteObject(m_bitmapGrid);
|
|
||||||
if (m_bitmapPlot != NULL) DeleteObject(m_bitmapPlot);
|
|
||||||
if (m_dcGrid != NULL) DeleteDC(m_dcGrid);
|
|
||||||
if (m_dcPlot != NULL) DeleteDC(m_dcPlot);
|
|
||||||
if (m_brushBack != NULL) DeleteObject(m_brushBack);
|
|
||||||
#if 0
|
|
||||||
for (int i = 0; i < MAX_CTRLS; i++) {
|
|
||||||
if (pCtrlArray[i] == this) {
|
|
||||||
pCtrlArray[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
BOOL TGraphCtrl::Create(HWND hWnd, HWND hParentWnd, UINT nID)
|
|
||||||
{
|
|
||||||
BOOL result = 0;
|
|
||||||
|
|
||||||
m_hParentWnd = hParentWnd;
|
|
||||||
m_hWnd = hWnd;
|
|
||||||
Resize();
|
|
||||||
if (result != 0)
|
|
||||||
InvalidateCtrl();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
BOOL TGraphCtrl::Create(DWORD dwStyle, const RECT& rect,
|
|
||||||
HWND hParentWnd, UINT nID)
|
|
||||||
{
|
|
||||||
BOOL result = 0;
|
|
||||||
|
|
||||||
m_hParentWnd = hParentWnd;
|
|
||||||
// GetClientRect(m_hParentWnd, &m_rectClient);
|
|
||||||
|
|
||||||
// set some member variables to avoid multiple function calls
|
|
||||||
m_nClientHeight = rect.bottom - rect.top;//rect.Height();
|
|
||||||
m_nClientWidth = rect.right - rect.left;//rect.Width();
|
|
||||||
// m_nClientHeight = cx;
|
|
||||||
// m_nClientWidth = cy;
|
|
||||||
|
|
||||||
// the "left" coordinate and "width" will be modified in
|
|
||||||
// InvalidateCtrl to be based on the width of the y axis scaling
|
|
||||||
#if 0
|
|
||||||
m_rectPlot.left = 20;
|
|
||||||
m_rectPlot.top = 10;
|
|
||||||
m_rectPlot.right = rect.right-10;
|
|
||||||
m_rectPlot.bottom = rect.bottom-25;
|
|
||||||
#else
|
|
||||||
m_rectPlot.left = -1;
|
|
||||||
m_rectPlot.top = -1;
|
|
||||||
m_rectPlot.right = rect.right-0;
|
|
||||||
m_rectPlot.bottom = rect.bottom-0;
|
|
||||||
#endif
|
|
||||||
// set some member variables to avoid multiple function calls
|
|
||||||
m_nPlotHeight = m_rectPlot.bottom - m_rectPlot.top;//m_rectPlot.Height();
|
|
||||||
m_nPlotWidth = m_rectPlot.right - m_rectPlot.left;//m_rectPlot.Width();
|
|
||||||
|
|
||||||
// set the scaling factor for now, this can be adjusted
|
|
||||||
// in the SetRange functions
|
|
||||||
m_dVerticalFactor = (double)m_nPlotHeight / m_dRange;
|
|
||||||
|
|
||||||
if (result != 0)
|
|
||||||
InvalidateCtrl();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
void TGraphCtrl::SetRange(double dLower, double dUpper, int nDecimalPlaces)
|
|
||||||
{
|
|
||||||
//ASSERT(dUpper > dLower);
|
|
||||||
m_dLowerLimit = dLower;
|
|
||||||
m_dUpperLimit = dUpper;
|
|
||||||
m_nYDecimals = nDecimalPlaces;
|
|
||||||
m_dRange = m_dUpperLimit - m_dLowerLimit;
|
|
||||||
m_dVerticalFactor = (double)m_nPlotHeight / m_dRange;
|
|
||||||
// clear out the existing garbage, re-start with a clean plot
|
|
||||||
InvalidateCtrl();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
void TGraphCtrl::SetXUnits(const char* string)
|
|
||||||
{
|
|
||||||
strncpy(m_strXUnitsString, string, sizeof(m_strXUnitsString) - 1);
|
|
||||||
// clear out the existing garbage, re-start with a clean plot
|
|
||||||
InvalidateCtrl();
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
void TGraphCtrl::SetYUnits(const char* string)
|
|
||||||
{
|
|
||||||
strncpy(m_strYUnitsString, string, sizeof(m_strYUnitsString) - 1);
|
|
||||||
// clear out the existing garbage, re-start with a clean plot
|
|
||||||
InvalidateCtrl();
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
void TGraphCtrl::SetGridColor(COLORREF color)
|
|
||||||
{
|
|
||||||
m_crGridColor = color;
|
|
||||||
// clear out the existing garbage, re-start with a clean plot
|
|
||||||
InvalidateCtrl();
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
void TGraphCtrl::SetPlotColor(int plot, COLORREF color)
|
|
||||||
{
|
|
||||||
m_crPlotColor[plot] = color;
|
|
||||||
DeleteObject(m_penPlot[plot]);
|
|
||||||
m_penPlot[plot] = CreatePen(PS_SOLID, 0, m_crPlotColor[plot]);
|
|
||||||
// clear out the existing garbage, re-start with a clean plot
|
|
||||||
InvalidateCtrl();
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
void TGraphCtrl::SetBackgroundColor(COLORREF color)
|
|
||||||
{
|
|
||||||
m_crBackColor = color;
|
|
||||||
DeleteObject(m_brushBack);
|
|
||||||
m_brushBack = CreateSolidBrush(m_crBackColor);
|
|
||||||
// clear out the existing garbage, re-start with a clean plot
|
|
||||||
InvalidateCtrl();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
void TGraphCtrl::InvalidateCtrl()
|
|
||||||
{
|
|
||||||
// There is a lot of drawing going on here - particularly in terms of
|
|
||||||
// drawing the grid. Don't panic, this is all being drawn (only once)
|
|
||||||
// to a bitmap. The result is then BitBlt'd to the control whenever needed.
|
|
||||||
int i, j;
|
|
||||||
int nCharacters;
|
|
||||||
int nTopGridPix, nMidGridPix, nBottomGridPix;
|
|
||||||
|
|
||||||
HPEN oldPen;
|
|
||||||
HPEN solidPen = CreatePen(PS_SOLID, 0, m_crGridColor);
|
|
||||||
//HFONT axisFont, yUnitFont, oldFont;
|
|
||||||
//char strTemp[50];
|
|
||||||
|
|
||||||
// in case we haven't established the memory dc's
|
|
||||||
//CClientDC dc(this);
|
|
||||||
HDC dc = GetDC(m_hParentWnd);
|
|
||||||
|
|
||||||
// if we don't have one yet, set up a memory dc for the grid
|
|
||||||
if (m_dcGrid == NULL) {
|
|
||||||
m_dcGrid = CreateCompatibleDC(dc);
|
|
||||||
m_bitmapGrid = CreateCompatibleBitmap(dc, m_nClientWidth, m_nClientHeight);
|
|
||||||
m_bitmapOldGrid = (HBITMAP)SelectObject(m_dcGrid, m_bitmapGrid);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetBkColor(m_dcGrid, m_crBackColor);
|
|
||||||
|
|
||||||
// fill the grid background
|
|
||||||
FillRect(m_dcGrid, &m_rectClient, m_brushBack);
|
|
||||||
|
|
||||||
// draw the plot rectangle:
|
|
||||||
// determine how wide the y axis scaling values are
|
|
||||||
nCharacters = abs((int)log10(fabs(m_dUpperLimit)));
|
|
||||||
nCharacters = max(nCharacters, abs((int)log10(fabs(m_dLowerLimit))));
|
|
||||||
|
|
||||||
// add the units digit, decimal point and a minus sign, and an extra space
|
|
||||||
// as well as the number of decimal places to display
|
|
||||||
nCharacters = nCharacters + 4 + m_nYDecimals;
|
|
||||||
|
|
||||||
// adjust the plot rectangle dimensions
|
|
||||||
// assume 6 pixels per character (this may need to be adjusted)
|
|
||||||
// m_rectPlot.left = m_rectClient.left + 6*(nCharacters);
|
|
||||||
m_rectPlot.left = m_rectClient.left;
|
|
||||||
m_nPlotWidth = m_rectPlot.right - m_rectPlot.left;//m_rectPlot.Width();
|
|
||||||
|
|
||||||
// draw the plot rectangle
|
|
||||||
oldPen = (HPEN)SelectObject(m_dcGrid, solidPen);
|
|
||||||
MoveToEx(m_dcGrid, m_rectPlot.left, m_rectPlot.top, NULL);
|
|
||||||
LineTo(m_dcGrid, m_rectPlot.right+1, m_rectPlot.top);
|
|
||||||
LineTo(m_dcGrid, m_rectPlot.right+1, m_rectPlot.bottom+1);
|
|
||||||
LineTo(m_dcGrid, m_rectPlot.left, m_rectPlot.bottom+1);
|
|
||||||
// LineTo(m_dcGrid, m_rectPlot.left, m_rectPlot.top);
|
|
||||||
SelectObject(m_dcGrid, oldPen);
|
|
||||||
DeleteObject(solidPen);
|
|
||||||
|
|
||||||
// draw the dotted lines,
|
|
||||||
// use SetPixel instead of a dotted pen - this allows for a
|
|
||||||
// finer dotted line and a more "technical" look
|
|
||||||
nMidGridPix = (m_rectPlot.top + m_rectPlot.bottom)/2;
|
|
||||||
nTopGridPix = nMidGridPix - m_nPlotHeight/4;
|
|
||||||
nBottomGridPix = nMidGridPix + m_nPlotHeight/4;
|
|
||||||
|
|
||||||
for (i=m_rectPlot.left; i<m_rectPlot.right; i+=2) {
|
|
||||||
SetPixel(m_dcGrid, i, nTopGridPix, m_crGridColor);
|
|
||||||
SetPixel(m_dcGrid, i, nMidGridPix, m_crGridColor);
|
|
||||||
SetPixel(m_dcGrid, i, nBottomGridPix, m_crGridColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=m_rectPlot.left; i<m_rectPlot.right; i+=10) {
|
|
||||||
for (j=m_rectPlot.top; j<m_rectPlot.bottom; j+=2) {
|
|
||||||
SetPixel(m_dcGrid, i, j, m_crGridColor);
|
|
||||||
// SetPixel(m_dcGrid, i, j, m_crGridColor);
|
|
||||||
// SetPixel(m_dcGrid, i, j, m_crGridColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
// create some fonts (horizontal and vertical)
|
|
||||||
// use a height of 14 pixels and 300 weight
|
|
||||||
// (these may need to be adjusted depending on the display)
|
|
||||||
axisFont = CreateFont (14, 0, 0, 0, 300,
|
|
||||||
FALSE, FALSE, 0, ANSI_CHARSET,
|
|
||||||
OUT_DEFAULT_PRECIS,
|
|
||||||
CLIP_DEFAULT_PRECIS,
|
|
||||||
DEFAULT_QUALITY,
|
|
||||||
DEFAULT_PITCH|FF_SWISS, "Arial");
|
|
||||||
yUnitFont = CreateFont (14, 0, 900, 0, 300,
|
|
||||||
FALSE, FALSE, 0, ANSI_CHARSET,
|
|
||||||
OUT_DEFAULT_PRECIS,
|
|
||||||
CLIP_DEFAULT_PRECIS,
|
|
||||||
DEFAULT_QUALITY,
|
|
||||||
DEFAULT_PITCH|FF_SWISS, "Arial");
|
|
||||||
|
|
||||||
// grab the horizontal font
|
|
||||||
oldFont = (HFONT)SelectObject(m_dcGrid, axisFont);
|
|
||||||
|
|
||||||
// y max
|
|
||||||
SetTextColor(m_dcGrid, m_crGridColor);
|
|
||||||
SetTextAlign(m_dcGrid, TA_RIGHT|TA_TOP);
|
|
||||||
sprintf(strTemp, "%.*lf", m_nYDecimals, m_dUpperLimit);
|
|
||||||
TextOut(m_dcGrid, m_rectPlot.left-4, m_rectPlot.top, strTemp, strlen(strTemp));
|
|
||||||
|
|
||||||
// y min
|
|
||||||
SetTextAlign(m_dcGrid, TA_RIGHT|TA_BASELINE);
|
|
||||||
sprintf(strTemp, "%.*lf", m_nYDecimals, m_dLowerLimit);
|
|
||||||
TextOut(m_dcGrid, m_rectPlot.left-4, m_rectPlot.bottom, strTemp, strlen(strTemp));
|
|
||||||
|
|
||||||
// x min
|
|
||||||
SetTextAlign(m_dcGrid, TA_LEFT|TA_TOP);
|
|
||||||
TextOut(m_dcGrid, m_rectPlot.left, m_rectPlot.bottom+4, "0", 1);
|
|
||||||
|
|
||||||
// x max
|
|
||||||
SetTextAlign(m_dcGrid, TA_RIGHT|TA_TOP);
|
|
||||||
sprintf(strTemp, "%d", m_nPlotWidth/m_nShiftPixels);
|
|
||||||
TextOut(m_dcGrid, m_rectPlot.right, m_rectPlot.bottom+4, strTemp, strlen(strTemp));
|
|
||||||
|
|
||||||
// x units
|
|
||||||
SetTextAlign(m_dcGrid, TA_CENTER|TA_TOP);
|
|
||||||
TextOut(m_dcGrid, (m_rectPlot.left+m_rectPlot.right)/2,
|
|
||||||
m_rectPlot.bottom+4, m_strXUnitsString, strlen(m_strXUnitsString));
|
|
||||||
|
|
||||||
// restore the font
|
|
||||||
SelectObject(m_dcGrid, oldFont);
|
|
||||||
|
|
||||||
// y units
|
|
||||||
oldFont = (HFONT)SelectObject(m_dcGrid, yUnitFont);
|
|
||||||
SetTextAlign(m_dcGrid, TA_CENTER|TA_BASELINE);
|
|
||||||
TextOut(m_dcGrid, (m_rectClient.left+m_rectPlot.left)/2,
|
|
||||||
(m_rectPlot.bottom+m_rectPlot.top)/2, m_strYUnitsString, strlen(m_strYUnitsString));
|
|
||||||
SelectObject(m_dcGrid, oldFont);
|
|
||||||
#endif
|
|
||||||
// at this point we are done filling the the grid bitmap,
|
|
||||||
// no more drawing to this bitmap is needed until the setting are changed
|
|
||||||
|
|
||||||
// if we don't have one yet, set up a memory dc for the plot
|
|
||||||
if (m_dcPlot == NULL) {
|
|
||||||
m_dcPlot = CreateCompatibleDC(dc);
|
|
||||||
m_bitmapPlot = CreateCompatibleBitmap(dc, m_nClientWidth, m_nClientHeight);
|
|
||||||
m_bitmapOldPlot = (HBITMAP)SelectObject(m_dcPlot, m_bitmapPlot);
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure the plot bitmap is cleared
|
|
||||||
SetBkColor(m_dcPlot, m_crBackColor);
|
|
||||||
FillRect(m_dcPlot, &m_rectClient, m_brushBack);
|
|
||||||
|
|
||||||
// finally, force the plot area to redraw
|
|
||||||
InvalidateRect(m_hParentWnd, &m_rectClient, TRUE);
|
|
||||||
ReleaseDC(m_hParentWnd, dc);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
double TGraphCtrl::AppendPoint(double dNewPoint0, double dNewPoint1,
|
|
||||||
double dNewPoint2, double dNewPoint3)
|
|
||||||
{
|
|
||||||
// append a data point to the plot & return the previous point
|
|
||||||
double dPrevious;
|
|
||||||
|
|
||||||
dPrevious = m_dCurrentPosition[0];
|
|
||||||
m_dCurrentPosition[0] = dNewPoint0;
|
|
||||||
m_dCurrentPosition[1] = dNewPoint1;
|
|
||||||
m_dCurrentPosition[2] = dNewPoint2;
|
|
||||||
m_dCurrentPosition[3] = dNewPoint3;
|
|
||||||
DrawPoint();
|
|
||||||
//Invalidate();
|
|
||||||
return dPrevious;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void TGraphCtrl::Paint(HWND hWnd, HDC dc)
|
|
||||||
{
|
|
||||||
HDC memDC;
|
|
||||||
HBITMAP memBitmap;
|
|
||||||
HBITMAP oldBitmap; // bitmap originally found in CMemDC
|
|
||||||
|
|
||||||
// RECT rcClient;
|
|
||||||
// GetClientRect(hWnd, &rcClient);
|
|
||||||
// FillSolidRect(dc, &rcClient, RGB(255, 0, 255));
|
|
||||||
// m_nClientWidth = rcClient.right - rcClient.left;
|
|
||||||
// m_nClientHeight = rcClient.bottom - rcClient.top;
|
|
||||||
|
|
||||||
// no real plotting work is performed here,
|
|
||||||
// just putting the existing bitmaps on the client
|
|
||||||
|
|
||||||
// to avoid flicker, establish a memory dc, draw to it
|
|
||||||
// and then BitBlt it to the client
|
|
||||||
memDC = CreateCompatibleDC(dc);
|
|
||||||
memBitmap = (HBITMAP)CreateCompatibleBitmap(dc, m_nClientWidth, m_nClientHeight);
|
|
||||||
oldBitmap = (HBITMAP)SelectObject(memDC, memBitmap);
|
|
||||||
|
|
||||||
if (memDC != NULL) {
|
|
||||||
// first drop the grid on the memory dc
|
|
||||||
BitBlt(memDC, 0, 0, m_nClientWidth, m_nClientHeight, m_dcGrid, 0, 0, SRCCOPY);
|
|
||||||
// now add the plot on top as a "pattern" via SRCPAINT.
|
|
||||||
// works well with dark background and a light plot
|
|
||||||
BitBlt(memDC, 0, 0, m_nClientWidth, m_nClientHeight, m_dcPlot, 0, 0, SRCPAINT); //SRCPAINT
|
|
||||||
// finally send the result to the display
|
|
||||||
BitBlt(dc, 0, 0, m_nClientWidth, m_nClientHeight, memDC, 0, 0, SRCCOPY);
|
|
||||||
}
|
|
||||||
SelectObject(memDC, oldBitmap);
|
|
||||||
DeleteObject(memBitmap);
|
|
||||||
DeleteDC(memDC);
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
void TGraphCtrl::DrawPoint()
|
|
||||||
{
|
|
||||||
// this does the work of "scrolling" the plot to the left
|
|
||||||
// and appending a new data point all of the plotting is
|
|
||||||
// directed to the memory based bitmap associated with m_dcPlot
|
|
||||||
// the will subsequently be BitBlt'd to the client in Paint
|
|
||||||
|
|
||||||
int currX, prevX, currY, prevY;
|
|
||||||
HPEN oldPen;
|
|
||||||
RECT rectCleanUp;
|
|
||||||
|
|
||||||
if (m_dcPlot != NULL) {
|
|
||||||
// shift the plot by BitBlt'ing it to itself
|
|
||||||
// note: the m_dcPlot covers the entire client
|
|
||||||
// but we only shift bitmap that is the size
|
|
||||||
// of the plot rectangle
|
|
||||||
// grab the right side of the plot (exluding m_nShiftPixels on the left)
|
|
||||||
// move this grabbed bitmap to the left by m_nShiftPixels
|
|
||||||
|
|
||||||
BitBlt(m_dcPlot, m_rectPlot.left, m_rectPlot.top+1,
|
|
||||||
m_nPlotWidth, m_nPlotHeight, m_dcPlot,
|
|
||||||
m_rectPlot.left+m_nShiftPixels, m_rectPlot.top+1,
|
|
||||||
SRCCOPY);
|
|
||||||
|
|
||||||
// establish a rectangle over the right side of plot
|
|
||||||
// which now needs to be cleaned up proir to adding the new point
|
|
||||||
rectCleanUp = m_rectPlot;
|
|
||||||
rectCleanUp.left = rectCleanUp.right - m_nShiftPixels;
|
|
||||||
|
|
||||||
// fill the cleanup area with the background
|
|
||||||
FillRect(m_dcPlot, &rectCleanUp, m_brushBack);
|
|
||||||
|
|
||||||
// draw the next line segement
|
|
||||||
for (int i = 0; i < MAX_PLOTS; i++) {
|
|
||||||
|
|
||||||
// grab the plotting pen
|
|
||||||
oldPen = (HPEN)SelectObject(m_dcPlot, m_penPlot[i]);
|
|
||||||
|
|
||||||
// move to the previous point
|
|
||||||
prevX = m_rectPlot.right-m_nPlotShiftPixels;
|
|
||||||
prevY = m_rectPlot.bottom -
|
|
||||||
(long)((m_dPreviousPosition[i] - m_dLowerLimit) * m_dVerticalFactor);
|
|
||||||
MoveToEx(m_dcPlot, prevX, prevY, NULL);
|
|
||||||
|
|
||||||
// draw to the current point
|
|
||||||
currX = m_rectPlot.right-m_nHalfShiftPixels;
|
|
||||||
currY = m_rectPlot.bottom -
|
|
||||||
(long)((m_dCurrentPosition[i] - m_dLowerLimit) * m_dVerticalFactor);
|
|
||||||
LineTo(m_dcPlot, currX, currY);
|
|
||||||
|
|
||||||
// restore the pen
|
|
||||||
SelectObject(m_dcPlot, oldPen);
|
|
||||||
|
|
||||||
// if the data leaks over the upper or lower plot boundaries
|
|
||||||
// fill the upper and lower leakage with the background
|
|
||||||
// this will facilitate clipping on an as needed basis
|
|
||||||
// as opposed to always calling IntersectClipRect
|
|
||||||
|
|
||||||
if ((prevY <= m_rectPlot.top) || (currY <= m_rectPlot.top)) {
|
|
||||||
RECT rc;
|
|
||||||
rc.bottom = m_rectPlot.top+1;
|
|
||||||
rc.left = prevX;
|
|
||||||
rc.right = currX+1;
|
|
||||||
rc.top = m_rectClient.top;
|
|
||||||
FillRect(m_dcPlot, &rc, m_brushBack);
|
|
||||||
}
|
|
||||||
if ((prevY >= m_rectPlot.bottom) || (currY >= m_rectPlot.bottom)) {
|
|
||||||
RECT rc;
|
|
||||||
rc.bottom = m_rectClient.bottom+1;
|
|
||||||
rc.left = prevX;
|
|
||||||
rc.right = currX+1;
|
|
||||||
rc.top = m_rectPlot.bottom+1;
|
|
||||||
//RECT rc(prevX, m_rectPlot.bottom+1, currX+1, m_rectClient.bottom+1);
|
|
||||||
FillRect(m_dcPlot, &rc, m_brushBack);
|
|
||||||
}
|
|
||||||
|
|
||||||
// store the current point for connection to the next point
|
|
||||||
m_dPreviousPosition[i] = m_dCurrentPosition[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
void TGraphCtrl::Resize(void)
|
|
||||||
{
|
|
||||||
// NOTE: Resize automatically gets called during the setup of the control
|
|
||||||
GetClientRect(m_hWnd, &m_rectClient);
|
|
||||||
|
|
||||||
// set some member variables to avoid multiple function calls
|
|
||||||
m_nClientHeight = m_rectClient.bottom - m_rectClient.top;//m_rectClient.Height();
|
|
||||||
m_nClientWidth = m_rectClient.right - m_rectClient.left;//m_rectClient.Width();
|
|
||||||
|
|
||||||
// the "left" coordinate and "width" will be modified in
|
|
||||||
// InvalidateCtrl to be based on the width of the y axis scaling
|
|
||||||
#if 0
|
|
||||||
m_rectPlot.left = 20;
|
|
||||||
m_rectPlot.top = 10;
|
|
||||||
m_rectPlot.right = m_rectClient.right-10;
|
|
||||||
m_rectPlot.bottom = m_rectClient.bottom-25;
|
|
||||||
#else
|
|
||||||
m_rectPlot.left = 0;
|
|
||||||
m_rectPlot.top = -1;
|
|
||||||
m_rectPlot.right = m_rectClient.right-0;
|
|
||||||
m_rectPlot.bottom = m_rectClient.bottom-0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// set some member variables to avoid multiple function calls
|
|
||||||
m_nPlotHeight = m_rectPlot.bottom - m_rectPlot.top;//m_rectPlot.Height();
|
|
||||||
m_nPlotWidth = m_rectPlot.right - m_rectPlot.left;//m_rectPlot.Width();
|
|
||||||
|
|
||||||
// set the scaling factor for now, this can be adjusted
|
|
||||||
// in the SetRange functions
|
|
||||||
m_dVerticalFactor = (double)m_nPlotHeight / m_dRange;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
void TGraphCtrl::Reset()
|
|
||||||
{
|
|
||||||
// to clear the existing data (in the form of a bitmap)
|
|
||||||
// simply invalidate the entire control
|
|
||||||
InvalidateCtrl();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
extern TGraphCtrl PerformancePageCpuUsageHistoryGraph;
|
|
||||||
extern TGraphCtrl PerformancePageMemUsageHistoryGraph;
|
|
||||||
extern HWND hPerformancePageCpuUsageHistoryGraph;
|
|
||||||
extern HWND hPerformancePageMemUsageHistoryGraph;
|
|
||||||
|
|
||||||
LRESULT CALLBACK GraphCtrl_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
RECT rcClient;
|
|
||||||
HDC hdc;
|
|
||||||
PAINTSTRUCT ps;
|
|
||||||
//LONG WindowId;
|
|
||||||
//TGraphCtrl* pGraphCtrl;
|
|
||||||
|
|
||||||
switch (message) {
|
|
||||||
case WM_ERASEBKGND:
|
|
||||||
return TRUE;
|
|
||||||
//
|
|
||||||
// Filter out mouse & keyboard messages
|
|
||||||
//
|
|
||||||
//case WM_APPCOMMAND:
|
|
||||||
case WM_CAPTURECHANGED:
|
|
||||||
case WM_LBUTTONDBLCLK:
|
|
||||||
case WM_LBUTTONDOWN:
|
|
||||||
case WM_LBUTTONUP:
|
|
||||||
case WM_MBUTTONDBLCLK:
|
|
||||||
case WM_MBUTTONDOWN:
|
|
||||||
case WM_MBUTTONUP:
|
|
||||||
case WM_MOUSEACTIVATE:
|
|
||||||
case WM_MOUSEHOVER:
|
|
||||||
case WM_MOUSELEAVE:
|
|
||||||
case WM_MOUSEMOVE:
|
|
||||||
//case WM_MOUSEWHEEL:
|
|
||||||
case WM_NCHITTEST:
|
|
||||||
case WM_NCLBUTTONDBLCLK:
|
|
||||||
case WM_NCLBUTTONDOWN:
|
|
||||||
case WM_NCLBUTTONUP:
|
|
||||||
case WM_NCMBUTTONDBLCLK:
|
|
||||||
case WM_NCMBUTTONDOWN:
|
|
||||||
case WM_NCMBUTTONUP:
|
|
||||||
//case WM_NCMOUSEHOVER:
|
|
||||||
//case WM_NCMOUSELEAVE:
|
|
||||||
case WM_NCMOUSEMOVE:
|
|
||||||
case WM_NCRBUTTONDBLCLK:
|
|
||||||
case WM_NCRBUTTONDOWN:
|
|
||||||
case WM_NCRBUTTONUP:
|
|
||||||
//case WM_NCXBUTTONDBLCLK:
|
|
||||||
//case WM_NCXBUTTONDOWN:
|
|
||||||
//case WM_NCXBUTTONUP:
|
|
||||||
case WM_RBUTTONDBLCLK:
|
|
||||||
case WM_RBUTTONDOWN:
|
|
||||||
case WM_RBUTTONUP:
|
|
||||||
//case WM_XBUTTONDBLCLK:
|
|
||||||
//case WM_XBUTTONDOWN:
|
|
||||||
//case WM_XBUTTONUP:
|
|
||||||
case WM_ACTIVATE:
|
|
||||||
case WM_CHAR:
|
|
||||||
case WM_DEADCHAR:
|
|
||||||
case WM_GETHOTKEY:
|
|
||||||
case WM_HOTKEY:
|
|
||||||
case WM_KEYDOWN:
|
|
||||||
case WM_KEYUP:
|
|
||||||
case WM_KILLFOCUS:
|
|
||||||
case WM_SETFOCUS:
|
|
||||||
case WM_SETHOTKEY:
|
|
||||||
case WM_SYSCHAR:
|
|
||||||
case WM_SYSDEADCHAR:
|
|
||||||
case WM_SYSKEYDOWN:
|
|
||||||
case WM_SYSKEYUP:
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case WM_NCCALCSIZE:
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case WM_SIZE:
|
|
||||||
// pGraphCtrl = TGraphCtrl::LookupGraphCtrl(hWnd);
|
|
||||||
// if (pGraphCtrl) pGraphCtrl->Resize(wParam, HIWORD(lParam), LOWORD(lParam));
|
|
||||||
if (hWnd == hPerformancePageMemUsageHistoryGraph) {
|
|
||||||
PerformancePageMemUsageHistoryGraph.Resize();
|
|
||||||
PerformancePageMemUsageHistoryGraph.InvalidateCtrl();
|
|
||||||
}
|
|
||||||
if (hWnd == hPerformancePageCpuUsageHistoryGraph) {
|
|
||||||
PerformancePageCpuUsageHistoryGraph.Resize();
|
|
||||||
PerformancePageCpuUsageHistoryGraph.InvalidateCtrl();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_PAINT:
|
|
||||||
hdc = BeginPaint(hWnd, &ps);
|
|
||||||
// pGraphCtrl = TGraphCtrl::LookupGraphCtrl(hWnd);
|
|
||||||
// if (pGraphCtrl) pGraphCtrl->Paint(hdc);
|
|
||||||
GetClientRect(hWnd, &rcClient);
|
|
||||||
if (hWnd == hPerformancePageMemUsageHistoryGraph) {
|
|
||||||
PerformancePageMemUsageHistoryGraph.Paint(hWnd, hdc);
|
|
||||||
}
|
|
||||||
if (hWnd == hPerformancePageCpuUsageHistoryGraph) {
|
|
||||||
PerformancePageCpuUsageHistoryGraph.Paint(hWnd, hdc);
|
|
||||||
}
|
|
||||||
EndPaint(hWnd, &ps);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// We pass on all non-handled messages
|
|
||||||
//
|
|
||||||
return CallWindowProc((WNDPROC)OldGraphCtrlWndProc, hWnd, message, wParam, lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
#include "GraphCtrl.h"
|
|
||||||
|
|
||||||
TGraphCtrl* TGraphCtrl::pCtrlArray[] = { 0, 0, 0, 0 };
|
|
||||||
int TGraphCtrl::CtrlCount = 0;
|
|
||||||
|
|
||||||
TGraphCtrl* TGraphCtrl::LookupGraphCtrl(HWND hWnd)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < MAX_CTRLS; i++) {
|
|
||||||
if (pCtrlArray[i] != 0) {
|
|
||||||
if (pCtrlArray[i]->m_hParentWnd == hWnd) {
|
|
||||||
return pCtrlArray[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,111 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* GraphCtrl.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GRAPH_CTRL_H__
|
|
||||||
#define __GRAPH_CTRL_H__
|
|
||||||
|
|
||||||
#define MAX_PLOTS 4
|
|
||||||
#define MAX_CTRLS 4
|
|
||||||
|
|
||||||
|
|
||||||
class TGraphCtrl
|
|
||||||
{
|
|
||||||
// Attributes
|
|
||||||
public:
|
|
||||||
double AppendPoint(double dNewPoint0, double dNewPoint1 = 0.0,
|
|
||||||
double dNewPoint2 = 0.0, double dNewPoint3 = 0.0);
|
|
||||||
void SetRange(double dLower, double dUpper, int nDecimalPlaces=1);
|
|
||||||
void SetXUnits(const char* string);
|
|
||||||
void SetYUnits(const char* string);
|
|
||||||
void SetGridColor(COLORREF color);
|
|
||||||
void SetPlotColor(int plot, COLORREF color);
|
|
||||||
void SetBackgroundColor(COLORREF color);
|
|
||||||
void InvalidateCtrl();
|
|
||||||
void DrawPoint();
|
|
||||||
void Reset();
|
|
||||||
|
|
||||||
// Operations
|
|
||||||
public:
|
|
||||||
BOOL Create(DWORD dwStyle, const RECT& rect, HWND hParentWnd, UINT nID=NULL);
|
|
||||||
BOOL Create(HWND hWnd, HWND hParentWnd, UINT nID=NULL);
|
|
||||||
void Paint(HWND hWnd, HDC dc);
|
|
||||||
void Resize(void);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static TGraphCtrl* LookupGraphCtrl(HWND hWnd);
|
|
||||||
static TGraphCtrl* pCtrlArray[MAX_CTRLS];
|
|
||||||
static int CtrlCount;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Implementation
|
|
||||||
public:
|
|
||||||
int m_nShiftPixels; // amount to shift with each new point
|
|
||||||
int m_nYDecimals;
|
|
||||||
|
|
||||||
char m_strXUnitsString[50];
|
|
||||||
char m_strYUnitsString[50];
|
|
||||||
|
|
||||||
COLORREF m_crBackColor; // background color
|
|
||||||
COLORREF m_crGridColor; // grid color
|
|
||||||
COLORREF m_crPlotColor[MAX_PLOTS]; // data color
|
|
||||||
|
|
||||||
double m_dCurrentPosition[MAX_PLOTS]; // current position
|
|
||||||
double m_dPreviousPosition[MAX_PLOTS]; // previous position
|
|
||||||
|
|
||||||
// Construction
|
|
||||||
public:
|
|
||||||
TGraphCtrl();
|
|
||||||
virtual ~TGraphCtrl();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int m_nHalfShiftPixels;
|
|
||||||
int m_nPlotShiftPixels;
|
|
||||||
int m_nClientHeight;
|
|
||||||
int m_nClientWidth;
|
|
||||||
int m_nPlotHeight;
|
|
||||||
int m_nPlotWidth;
|
|
||||||
|
|
||||||
double m_dLowerLimit; // lower bounds
|
|
||||||
double m_dUpperLimit; // upper bounds
|
|
||||||
double m_dRange;
|
|
||||||
double m_dVerticalFactor;
|
|
||||||
|
|
||||||
HWND m_hWnd;
|
|
||||||
HWND m_hParentWnd;
|
|
||||||
HDC m_dcGrid;
|
|
||||||
HDC m_dcPlot;
|
|
||||||
HBITMAP m_bitmapOldGrid;
|
|
||||||
HBITMAP m_bitmapOldPlot;
|
|
||||||
HBITMAP m_bitmapGrid;
|
|
||||||
HBITMAP m_bitmapPlot;
|
|
||||||
HBRUSH m_brushBack;
|
|
||||||
HPEN m_penPlot[MAX_PLOTS];
|
|
||||||
RECT m_rectClient;
|
|
||||||
RECT m_rectPlot;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern LONG OldGraphCtrlWndProc;
|
|
||||||
|
|
||||||
LRESULT CALLBACK GraphCtrl_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GRAPH_CTRL_H__ */
|
|
|
@ -1,522 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* performancepage.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include "stdafx.h"
|
|
||||||
#else
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "TaskMgr.h"
|
|
||||||
#include "PerformancePage.h"
|
|
||||||
#include "perfdata.h"
|
|
||||||
|
|
||||||
#include "graph.h"
|
|
||||||
#include "GraphCtrl.h"
|
|
||||||
|
|
||||||
TGraphCtrl PerformancePageCpuUsageHistoryGraph;
|
|
||||||
TGraphCtrl PerformancePageMemUsageHistoryGraph;
|
|
||||||
|
|
||||||
HWND hPerformancePage; // Performance Property Page
|
|
||||||
|
|
||||||
HWND hPerformancePageCpuUsageGraph; // CPU Usage Graph
|
|
||||||
HWND hPerformancePageMemUsageGraph; // MEM Usage Graph
|
|
||||||
HWND hPerformancePageCpuUsageHistoryGraph; // CPU Usage History Graph
|
|
||||||
HWND hPerformancePageMemUsageHistoryGraph; // Memory Usage History Graph
|
|
||||||
|
|
||||||
HWND hPerformancePageTotalsFrame; // Totals Frame
|
|
||||||
HWND hPerformancePageCommitChargeFrame; // Commit Charge Frame
|
|
||||||
HWND hPerformancePageKernelMemoryFrame; // Kernel Memory Frame
|
|
||||||
HWND hPerformancePagePhysicalMemoryFrame; // Physical Memory Frame
|
|
||||||
|
|
||||||
HWND hPerformancePageCpuUsageFrame;
|
|
||||||
HWND hPerformancePageMemUsageFrame;
|
|
||||||
HWND hPerformancePageCpuUsageHistoryFrame;
|
|
||||||
HWND hPerformancePageMemUsageHistoryFrame;
|
|
||||||
|
|
||||||
HWND hPerformancePageCommitChargeTotalEdit; // Commit Charge Total Edit Control
|
|
||||||
HWND hPerformancePageCommitChargeLimitEdit; // Commit Charge Limit Edit Control
|
|
||||||
HWND hPerformancePageCommitChargePeakEdit; // Commit Charge Peak Edit Control
|
|
||||||
|
|
||||||
HWND hPerformancePageKernelMemoryTotalEdit; // Kernel Memory Total Edit Control
|
|
||||||
HWND hPerformancePageKernelMemoryPagedEdit; // Kernel Memory Paged Edit Control
|
|
||||||
HWND hPerformancePageKernelMemoryNonPagedEdit; // Kernel Memory NonPaged Edit Control
|
|
||||||
|
|
||||||
HWND hPerformancePagePhysicalMemoryTotalEdit; // Physical Memory Total Edit Control
|
|
||||||
HWND hPerformancePagePhysicalMemoryAvailableEdit; // Physical Memory Available Edit Control
|
|
||||||
HWND hPerformancePagePhysicalMemorySystemCacheEdit; // Physical Memory System Cache Edit Control
|
|
||||||
|
|
||||||
HWND hPerformancePageTotalsHandleCountEdit; // Total Handles Edit Control
|
|
||||||
HWND hPerformancePageTotalsProcessCountEdit; // Total Processes Edit Control
|
|
||||||
HWND hPerformancePageTotalsThreadCountEdit; // Total Threads Edit Control
|
|
||||||
|
|
||||||
|
|
||||||
static int nPerformancePageWidth;
|
|
||||||
static int nPerformancePageHeight;
|
|
||||||
|
|
||||||
static HANDLE hPerformancePageEvent = NULL; // When this event becomes signaled then we refresh the performance page
|
|
||||||
|
|
||||||
void PerformancePageRefreshThread(void *lpParameter);
|
|
||||||
|
|
||||||
void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference, int pos)
|
|
||||||
{
|
|
||||||
RECT rc;
|
|
||||||
int cx, cy, sx, sy;
|
|
||||||
|
|
||||||
GetClientRect(hCntrl, &rc);
|
|
||||||
MapWindowPoints(hCntrl, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)));
|
|
||||||
if (pos) {
|
|
||||||
cx = rc.left;
|
|
||||||
cy = rc.top;
|
|
||||||
sx = rc.right - rc.left;
|
|
||||||
switch (pos) {
|
|
||||||
case 1:
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
cy += nYDifference / 2;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
sx += nXDifference;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
cy += nYDifference / 2;
|
|
||||||
sx += nXDifference;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
sy = rc.bottom - rc.top + nYDifference / 2;
|
|
||||||
SetWindowPos(hCntrl, NULL, cx, cy, sx, sy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER);
|
|
||||||
} else {
|
|
||||||
cx = rc.left + nXDifference;
|
|
||||||
cy = rc.top + nYDifference;
|
|
||||||
sx = sy = 0;
|
|
||||||
SetWindowPos(hCntrl, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
|
||||||
}
|
|
||||||
InvalidateRect(hCntrl, NULL, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AdjustControlPostion(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference)
|
|
||||||
{
|
|
||||||
AdjustFrameSize(hCntrl, hDlg, nXDifference, nYDifference, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AdjustCntrlPos(int ctrl_id, HWND hDlg, int nXDifference, int nYDifference)
|
|
||||||
{
|
|
||||||
AdjustFrameSize(GetDlgItem(hDlg, ctrl_id), hDlg, nXDifference, nYDifference, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
RECT rc;
|
|
||||||
int nXDifference;
|
|
||||||
int nYDifference;
|
|
||||||
|
|
||||||
HDC hdc;
|
|
||||||
PAINTSTRUCT ps;
|
|
||||||
|
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
case WM_INITDIALOG:
|
|
||||||
|
|
||||||
// Save the width and height
|
|
||||||
GetClientRect(hDlg, &rc);
|
|
||||||
nPerformancePageWidth = rc.right;
|
|
||||||
nPerformancePageHeight = rc.bottom;
|
|
||||||
|
|
||||||
// Update window position
|
|
||||||
SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get handles to all the controls
|
|
||||||
//
|
|
||||||
hPerformancePageTotalsFrame = GetDlgItem(hDlg, IDC_TOTALS_FRAME);
|
|
||||||
hPerformancePageCommitChargeFrame = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_FRAME);
|
|
||||||
hPerformancePageKernelMemoryFrame = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_FRAME);
|
|
||||||
hPerformancePagePhysicalMemoryFrame = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_FRAME);
|
|
||||||
|
|
||||||
hPerformancePageCpuUsageFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_FRAME);
|
|
||||||
hPerformancePageMemUsageFrame = GetDlgItem(hDlg, IDC_MEM_USAGE_FRAME);
|
|
||||||
hPerformancePageCpuUsageHistoryFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_FRAME);
|
|
||||||
hPerformancePageMemUsageHistoryFrame = GetDlgItem(hDlg, IDC_MEMORY_USAGE_HISTORY_FRAME);
|
|
||||||
|
|
||||||
hPerformancePageCommitChargeTotalEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_TOTAL);
|
|
||||||
hPerformancePageCommitChargeLimitEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_LIMIT);
|
|
||||||
hPerformancePageCommitChargePeakEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_PEAK);
|
|
||||||
hPerformancePageKernelMemoryTotalEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_TOTAL);
|
|
||||||
hPerformancePageKernelMemoryPagedEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_PAGED);
|
|
||||||
hPerformancePageKernelMemoryNonPagedEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_NONPAGED);
|
|
||||||
hPerformancePagePhysicalMemoryTotalEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_TOTAL);
|
|
||||||
hPerformancePagePhysicalMemoryAvailableEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_AVAILABLE);
|
|
||||||
hPerformancePagePhysicalMemorySystemCacheEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_SYSTEM_CACHE);
|
|
||||||
hPerformancePageTotalsHandleCountEdit = GetDlgItem(hDlg, IDC_TOTALS_HANDLE_COUNT);
|
|
||||||
hPerformancePageTotalsProcessCountEdit = GetDlgItem(hDlg, IDC_TOTALS_PROCESS_COUNT);
|
|
||||||
hPerformancePageTotalsThreadCountEdit = GetDlgItem(hDlg, IDC_TOTALS_THREAD_COUNT);
|
|
||||||
|
|
||||||
hPerformancePageCpuUsageGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_GRAPH);
|
|
||||||
hPerformancePageMemUsageGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_GRAPH);
|
|
||||||
hPerformancePageMemUsageHistoryGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_HISTORY_GRAPH);
|
|
||||||
hPerformancePageCpuUsageHistoryGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
|
|
||||||
|
|
||||||
GetClientRect(hPerformancePageCpuUsageHistoryGraph, &rc);
|
|
||||||
// create the control
|
|
||||||
//PerformancePageCpuUsageHistoryGraph.Create(0, rc, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
|
|
||||||
PerformancePageCpuUsageHistoryGraph.Create(hPerformancePageCpuUsageHistoryGraph, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
|
|
||||||
// customize the control
|
|
||||||
PerformancePageCpuUsageHistoryGraph.SetRange(0.0, 100.0, 10) ;
|
|
||||||
// PerformancePageCpuUsageHistoryGraph.SetYUnits("Current") ;
|
|
||||||
// PerformancePageCpuUsageHistoryGraph.SetXUnits("Samples (Windows Timer: 100 msec)") ;
|
|
||||||
// PerformancePageCpuUsageHistoryGraph.SetBackgroundColor(RGB(0, 0, 64)) ;
|
|
||||||
// PerformancePageCpuUsageHistoryGraph.SetGridColor(RGB(192, 192, 255)) ;
|
|
||||||
// PerformancePageCpuUsageHistoryGraph.SetPlotColor(RGB(255, 255, 255)) ;
|
|
||||||
PerformancePageCpuUsageHistoryGraph.SetBackgroundColor(RGB(0, 0, 0)) ;
|
|
||||||
PerformancePageCpuUsageHistoryGraph.SetGridColor(RGB(152, 205, 152)) ;
|
|
||||||
PerformancePageCpuUsageHistoryGraph.SetPlotColor(0, RGB(255, 0, 0)) ;
|
|
||||||
PerformancePageCpuUsageHistoryGraph.SetPlotColor(1, RGB(0, 255, 0)) ;
|
|
||||||
|
|
||||||
GetClientRect(hPerformancePageMemUsageHistoryGraph, &rc);
|
|
||||||
PerformancePageMemUsageHistoryGraph.Create(hPerformancePageMemUsageHistoryGraph, hDlg, IDC_MEM_USAGE_HISTORY_GRAPH);
|
|
||||||
PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ;
|
|
||||||
PerformancePageMemUsageHistoryGraph.SetBackgroundColor(RGB(0, 0, 0)) ;
|
|
||||||
PerformancePageMemUsageHistoryGraph.SetGridColor(RGB(152, 215, 152)) ;
|
|
||||||
PerformancePageMemUsageHistoryGraph.SetPlotColor(0, RGB(255, 255, 0)) ;
|
|
||||||
|
|
||||||
// Start our refresh thread
|
|
||||||
#ifdef RUN_PERF_PAGE
|
|
||||||
_beginthread(PerformancePageRefreshThread, 0, NULL);
|
|
||||||
#endif
|
|
||||||
//
|
|
||||||
// Subclass graph buttons
|
|
||||||
//
|
|
||||||
OldGraphWndProc = SetWindowLong(hPerformancePageCpuUsageGraph, GWL_WNDPROC, (LONG)Graph_WndProc);
|
|
||||||
SetWindowLong(hPerformancePageMemUsageGraph, GWL_WNDPROC, (LONG)Graph_WndProc);
|
|
||||||
OldGraphCtrlWndProc = SetWindowLong(hPerformancePageMemUsageHistoryGraph, GWL_WNDPROC, (LONG)GraphCtrl_WndProc);
|
|
||||||
SetWindowLong(hPerformancePageCpuUsageHistoryGraph, GWL_WNDPROC, (LONG)GraphCtrl_WndProc);
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case WM_COMMAND:
|
|
||||||
break;
|
|
||||||
#if 0
|
|
||||||
case WM_NCPAINT:
|
|
||||||
hdc = GetDC(hDlg);
|
|
||||||
GetClientRect(hDlg, &rc);
|
|
||||||
Draw3dRect(hdc, rc.left, rc.top, rc.right, rc.top + 2, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
|
|
||||||
ReleaseDC(hDlg, hdc);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_PAINT:
|
|
||||||
hdc = BeginPaint(hDlg, &ps);
|
|
||||||
GetClientRect(hDlg, &rc);
|
|
||||||
Draw3dRect(hdc, rc.left, rc.top, rc.right, rc.top + 2, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
|
|
||||||
EndPaint(hDlg, &ps);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case WM_SIZE:
|
|
||||||
int cx, cy;
|
|
||||||
|
|
||||||
if (wParam == SIZE_MINIMIZED)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
cx = LOWORD(lParam);
|
|
||||||
cy = HIWORD(lParam);
|
|
||||||
nXDifference = cx - nPerformancePageWidth;
|
|
||||||
nYDifference = cy - nPerformancePageHeight;
|
|
||||||
nPerformancePageWidth = cx;
|
|
||||||
nPerformancePageHeight = cy;
|
|
||||||
|
|
||||||
// Reposition the performance page's controls
|
|
||||||
AdjustFrameSize(hPerformancePageTotalsFrame, hDlg, 0, nYDifference, 0);
|
|
||||||
AdjustFrameSize(hPerformancePageCommitChargeFrame, hDlg, 0, nYDifference, 0);
|
|
||||||
AdjustFrameSize(hPerformancePageKernelMemoryFrame, hDlg, 0, nYDifference, 0);
|
|
||||||
AdjustFrameSize(hPerformancePagePhysicalMemoryFrame, hDlg, 0, nYDifference, 0);
|
|
||||||
AdjustCntrlPos(IDS_COMMIT_CHARGE_TOTAL, hDlg, 0, nYDifference);
|
|
||||||
AdjustCntrlPos(IDS_COMMIT_CHARGE_LIMIT, hDlg, 0, nYDifference);
|
|
||||||
AdjustCntrlPos(IDS_COMMIT_CHARGE_PEAK, hDlg, 0, nYDifference);
|
|
||||||
AdjustCntrlPos(IDS_KERNEL_MEMORY_TOTAL, hDlg, 0, nYDifference);
|
|
||||||
AdjustCntrlPos(IDS_KERNEL_MEMORY_PAGED, hDlg, 0, nYDifference);
|
|
||||||
AdjustCntrlPos(IDS_KERNEL_MEMORY_NONPAGED, hDlg, 0, nYDifference);
|
|
||||||
AdjustCntrlPos(IDS_PHYSICAL_MEMORY_TOTAL, hDlg, 0, nYDifference);
|
|
||||||
AdjustCntrlPos(IDS_PHYSICAL_MEMORY_AVAILABLE, hDlg, 0, nYDifference);
|
|
||||||
AdjustCntrlPos(IDS_PHYSICAL_MEMORY_SYSTEM_CACHE, hDlg, 0, nYDifference);
|
|
||||||
AdjustCntrlPos(IDS_TOTALS_HANDLE_COUNT, hDlg, 0, nYDifference);
|
|
||||||
AdjustCntrlPos(IDS_TOTALS_PROCESS_COUNT, hDlg, 0, nYDifference);
|
|
||||||
AdjustCntrlPos(IDS_TOTALS_THREAD_COUNT, hDlg, 0, nYDifference);
|
|
||||||
|
|
||||||
AdjustControlPostion(hPerformancePageCommitChargeTotalEdit, hDlg, 0, nYDifference);
|
|
||||||
AdjustControlPostion(hPerformancePageCommitChargeLimitEdit, hDlg, 0, nYDifference);
|
|
||||||
AdjustControlPostion(hPerformancePageCommitChargePeakEdit, hDlg, 0, nYDifference);
|
|
||||||
AdjustControlPostion(hPerformancePageKernelMemoryTotalEdit, hDlg, 0, nYDifference);
|
|
||||||
AdjustControlPostion(hPerformancePageKernelMemoryPagedEdit, hDlg, 0, nYDifference);
|
|
||||||
AdjustControlPostion(hPerformancePageKernelMemoryNonPagedEdit, hDlg, 0, nYDifference);
|
|
||||||
AdjustControlPostion(hPerformancePagePhysicalMemoryTotalEdit, hDlg, 0, nYDifference);
|
|
||||||
AdjustControlPostion(hPerformancePagePhysicalMemoryAvailableEdit, hDlg, 0, nYDifference);
|
|
||||||
AdjustControlPostion(hPerformancePagePhysicalMemorySystemCacheEdit, hDlg, 0, nYDifference);
|
|
||||||
AdjustControlPostion(hPerformancePageTotalsHandleCountEdit, hDlg, 0, nYDifference);
|
|
||||||
AdjustControlPostion(hPerformancePageTotalsProcessCountEdit, hDlg, 0, nYDifference);
|
|
||||||
AdjustControlPostion(hPerformancePageTotalsThreadCountEdit, hDlg, 0, nYDifference);
|
|
||||||
|
|
||||||
static int lastX, lastY;
|
|
||||||
|
|
||||||
nXDifference += lastX;
|
|
||||||
nYDifference += lastY;
|
|
||||||
lastX = lastY = 0;
|
|
||||||
if (nXDifference % 2) {
|
|
||||||
if (nXDifference > 0) {
|
|
||||||
nXDifference--;
|
|
||||||
lastX++;
|
|
||||||
} else {
|
|
||||||
nXDifference++;
|
|
||||||
lastX--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (nYDifference % 2) {
|
|
||||||
if (nYDifference > 0) {
|
|
||||||
nYDifference--;
|
|
||||||
lastY++;
|
|
||||||
} else {
|
|
||||||
nYDifference++;
|
|
||||||
lastY--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AdjustFrameSize(hPerformancePageCpuUsageFrame, hDlg, nXDifference, nYDifference, 1);
|
|
||||||
AdjustFrameSize(hPerformancePageMemUsageFrame, hDlg, nXDifference, nYDifference, 2);
|
|
||||||
AdjustFrameSize(hPerformancePageCpuUsageHistoryFrame, hDlg, nXDifference, nYDifference, 3);
|
|
||||||
AdjustFrameSize(hPerformancePageMemUsageHistoryFrame, hDlg, nXDifference, nYDifference, 4);
|
|
||||||
AdjustFrameSize(hPerformancePageCpuUsageGraph, hDlg, nXDifference, nYDifference, 1);
|
|
||||||
AdjustFrameSize(hPerformancePageMemUsageGraph, hDlg, nXDifference, nYDifference, 2);
|
|
||||||
AdjustFrameSize(hPerformancePageCpuUsageHistoryGraph, hDlg, nXDifference, nYDifference, 3);
|
|
||||||
AdjustFrameSize(hPerformancePageMemUsageHistoryGraph, hDlg, nXDifference, nYDifference, 4);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RefreshPerformancePage(void)
|
|
||||||
{
|
|
||||||
// Signal the event so that our refresh thread
|
|
||||||
// will wake up and refresh the performance page
|
|
||||||
SetEvent(hPerformancePageEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PerformancePageRefreshThread(void *lpParameter)
|
|
||||||
{
|
|
||||||
ULONG CommitChargeTotal;
|
|
||||||
ULONG CommitChargeLimit;
|
|
||||||
ULONG CommitChargePeak;
|
|
||||||
|
|
||||||
ULONG KernelMemoryTotal;
|
|
||||||
ULONG KernelMemoryPaged;
|
|
||||||
ULONG KernelMemoryNonPaged;
|
|
||||||
|
|
||||||
ULONG PhysicalMemoryTotal;
|
|
||||||
ULONG PhysicalMemoryAvailable;
|
|
||||||
ULONG PhysicalMemorySystemCache;
|
|
||||||
|
|
||||||
ULONG TotalHandles;
|
|
||||||
ULONG TotalThreads;
|
|
||||||
ULONG TotalProcesses;
|
|
||||||
|
|
||||||
TCHAR Text[260];
|
|
||||||
|
|
||||||
// Create the event
|
|
||||||
hPerformancePageEvent = CreateEvent(NULL, TRUE, TRUE, "Performance Page Event");
|
|
||||||
|
|
||||||
// If we couldn't create the event then exit the thread
|
|
||||||
if (!hPerformancePageEvent)
|
|
||||||
return;
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
DWORD dwWaitVal;
|
|
||||||
|
|
||||||
// Wait on the event
|
|
||||||
dwWaitVal = WaitForSingleObject(hPerformancePageEvent, INFINITE);
|
|
||||||
|
|
||||||
// If the wait failed then the event object must have been
|
|
||||||
// closed and the task manager is exiting so exit this thread
|
|
||||||
if (dwWaitVal == WAIT_FAILED)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (dwWaitVal == WAIT_OBJECT_0)
|
|
||||||
{
|
|
||||||
// Reset our event
|
|
||||||
ResetEvent(hPerformancePageEvent);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Update the commit charge info
|
|
||||||
//
|
|
||||||
CommitChargeTotal = PerfDataGetCommitChargeTotalK();
|
|
||||||
CommitChargeLimit = PerfDataGetCommitChargeLimitK();
|
|
||||||
CommitChargePeak = PerfDataGetCommitChargePeakK();
|
|
||||||
_ultot(CommitChargeTotal, Text, 10);
|
|
||||||
SetWindowText(hPerformancePageCommitChargeTotalEdit, Text);
|
|
||||||
_ultot(CommitChargeLimit, Text, 10);
|
|
||||||
SetWindowText(hPerformancePageCommitChargeLimitEdit, Text);
|
|
||||||
_ultot(CommitChargePeak, Text, 10);
|
|
||||||
SetWindowText(hPerformancePageCommitChargePeakEdit, Text);
|
|
||||||
wsprintf(Text, _T("Mem Usage: %dK / %dK"), CommitChargeTotal, CommitChargeLimit);
|
|
||||||
SendMessage(hStatusWnd, SB_SETTEXT, 2, (LPARAM)Text);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Update the kernel memory info
|
|
||||||
//
|
|
||||||
KernelMemoryTotal = PerfDataGetKernelMemoryTotalK();
|
|
||||||
KernelMemoryPaged = PerfDataGetKernelMemoryPagedK();
|
|
||||||
KernelMemoryNonPaged = PerfDataGetKernelMemoryNonPagedK();
|
|
||||||
_ultot(KernelMemoryTotal, Text, 10);
|
|
||||||
SetWindowText(hPerformancePageKernelMemoryTotalEdit, Text);
|
|
||||||
_ultot(KernelMemoryPaged, Text, 10);
|
|
||||||
SetWindowText(hPerformancePageKernelMemoryPagedEdit, Text);
|
|
||||||
_ultot(KernelMemoryNonPaged, Text, 10);
|
|
||||||
SetWindowText(hPerformancePageKernelMemoryNonPagedEdit, Text);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Update the physical memory info
|
|
||||||
//
|
|
||||||
PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
|
|
||||||
PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
|
|
||||||
PhysicalMemorySystemCache = PerfDataGetPhysicalMemorySystemCacheK();
|
|
||||||
_ultot(PhysicalMemoryTotal, Text, 10);
|
|
||||||
SetWindowText(hPerformancePagePhysicalMemoryTotalEdit, Text);
|
|
||||||
_ultot(PhysicalMemoryAvailable, Text, 10);
|
|
||||||
SetWindowText(hPerformancePagePhysicalMemoryAvailableEdit, Text);
|
|
||||||
_ultot(PhysicalMemorySystemCache, Text, 10);
|
|
||||||
SetWindowText(hPerformancePagePhysicalMemorySystemCacheEdit, Text);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Update the totals info
|
|
||||||
//
|
|
||||||
TotalHandles = PerfDataGetSystemHandleCount();
|
|
||||||
TotalThreads = PerfDataGetTotalThreadCount();
|
|
||||||
TotalProcesses = PerfDataGetProcessCount();
|
|
||||||
_ultot(TotalHandles, Text, 10);
|
|
||||||
SetWindowText(hPerformancePageTotalsHandleCountEdit, Text);
|
|
||||||
_ultot(TotalThreads, Text, 10);
|
|
||||||
SetWindowText(hPerformancePageTotalsThreadCountEdit, Text);
|
|
||||||
_ultot(TotalProcesses, Text, 10);
|
|
||||||
SetWindowText(hPerformancePageTotalsProcessCountEdit, Text);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Redraw the graphs
|
|
||||||
//
|
|
||||||
InvalidateRect(hPerformancePageCpuUsageGraph, NULL, FALSE);
|
|
||||||
InvalidateRect(hPerformancePageMemUsageGraph, NULL, FALSE);
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
ULONG CpuUsage;
|
|
||||||
ULONG CpuKernelUsage;
|
|
||||||
ULONGLONG CommitChargeTotal;
|
|
||||||
ULONGLONG CommitChargeLimit;
|
|
||||||
ULONG PhysicalMemoryTotal;
|
|
||||||
ULONG PhysicalMemoryAvailable;
|
|
||||||
int nBarsUsed1;
|
|
||||||
int nBarsUsed2;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get the CPU usage
|
|
||||||
//
|
|
||||||
CpuUsage = PerfDataGetProcessorUsage();
|
|
||||||
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
|
|
||||||
if (CpuUsage < 0 ) CpuUsage = 0;
|
|
||||||
if (CpuUsage > 100) CpuUsage = 100;
|
|
||||||
if (CpuKernelUsage < 0) CpuKernelUsage = 0;
|
|
||||||
if (CpuKernelUsage > 100) CpuKernelUsage = 100;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get the memory usage
|
|
||||||
//
|
|
||||||
CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
|
|
||||||
CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
|
|
||||||
nBarsUsed1 = ((CommitChargeTotal * 100) / CommitChargeLimit);
|
|
||||||
|
|
||||||
PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
|
|
||||||
PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
|
|
||||||
nBarsUsed2 = ((PhysicalMemoryAvailable * 100) / PhysicalMemoryTotal);
|
|
||||||
|
|
||||||
|
|
||||||
PerformancePageCpuUsageHistoryGraph.AppendPoint(CpuUsage, CpuKernelUsage);
|
|
||||||
PerformancePageMemUsageHistoryGraph.AppendPoint(nBarsUsed1, nBarsUsed2);
|
|
||||||
//PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ;
|
|
||||||
InvalidateRect(hPerformancePageMemUsageHistoryGraph, NULL, FALSE);
|
|
||||||
InvalidateRect(hPerformancePageCpuUsageHistoryGraph, NULL, FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PerformancePage_OnViewShowKernelTimes(void)
|
|
||||||
{
|
|
||||||
HMENU hMenu;
|
|
||||||
HMENU hViewMenu;
|
|
||||||
|
|
||||||
hMenu = GetMenu(hMainWnd);
|
|
||||||
hViewMenu = GetSubMenu(hMenu, 2);
|
|
||||||
|
|
||||||
// Check or uncheck the show 16-bit tasks menu item
|
|
||||||
if (GetMenuState(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND) & MF_CHECKED)
|
|
||||||
{
|
|
||||||
CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_UNCHECKED);
|
|
||||||
TaskManagerSettings.ShowKernelTimes = FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_CHECKED);
|
|
||||||
TaskManagerSettings.ShowKernelTimes = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
RefreshPerformancePage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PerformancePage_OnViewCPUHistoryOneGraphAll(void)
|
|
||||||
{
|
|
||||||
HMENU hMenu;
|
|
||||||
HMENU hViewMenu;
|
|
||||||
HMENU hCPUHistoryMenu;
|
|
||||||
|
|
||||||
hMenu = GetMenu(hMainWnd);
|
|
||||||
hViewMenu = GetSubMenu(hMenu, 2);
|
|
||||||
hCPUHistoryMenu = GetSubMenu(hViewMenu, 3);
|
|
||||||
|
|
||||||
TaskManagerSettings.CPUHistory_OneGraphPerCPU = FALSE;
|
|
||||||
CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHALL, MF_BYCOMMAND);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PerformancePage_OnViewCPUHistoryOneGraphPerCPU(void)
|
|
||||||
{
|
|
||||||
HMENU hMenu;
|
|
||||||
HMENU hViewMenu;
|
|
||||||
HMENU hCPUHistoryMenu;
|
|
||||||
|
|
||||||
hMenu = GetMenu(hMainWnd);
|
|
||||||
hViewMenu = GetSubMenu(hMenu, 2);
|
|
||||||
hCPUHistoryMenu = GetSubMenu(hViewMenu, 3);
|
|
||||||
|
|
||||||
TaskManagerSettings.CPUHistory_OneGraphPerCPU = TRUE;
|
|
||||||
CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, MF_BYCOMMAND);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* performancepage.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __PERFORMANCEPAGE_H
|
|
||||||
#define __PERFORMANCEPAGE_H
|
|
||||||
|
|
||||||
extern HWND hPerformancePage; // Performance Property Page
|
|
||||||
|
|
||||||
LRESULT CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
|
||||||
void RefreshPerformancePage(void);
|
|
||||||
|
|
||||||
void PerformancePage_OnViewShowKernelTimes(void);
|
|
||||||
void PerformancePage_OnViewCPUHistoryOneGraphAll(void);
|
|
||||||
void PerformancePage_OnViewCPUHistoryOneGraphPerCPU(void);
|
|
||||||
|
|
||||||
#endif // __PERFORMANCEPAGE_H
|
|
|
@ -1,549 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* processpage.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include "stdafx.h"
|
|
||||||
#else
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "TaskMgr.h"
|
|
||||||
#include "ProcessPage.h"
|
|
||||||
#include "perfdata.h"
|
|
||||||
#include "column.h"
|
|
||||||
#include "proclist.h"
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
HWND hProcessPage; // Process List Property Page
|
|
||||||
|
|
||||||
HWND hProcessPageListCtrl; // Process ListCtrl Window
|
|
||||||
HWND hProcessPageHeaderCtrl; // Process Header Control
|
|
||||||
HWND hProcessPageEndProcessButton; // Process End Process button
|
|
||||||
HWND hProcessPageShowAllProcessesButton;// Process Show All Processes checkbox
|
|
||||||
|
|
||||||
static int nProcessPageWidth;
|
|
||||||
static int nProcessPageHeight;
|
|
||||||
|
|
||||||
static HANDLE hProcessPageEvent = NULL; // When this event becomes signaled then we refresh the process list
|
|
||||||
|
|
||||||
void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam);
|
|
||||||
void CommaSeparateNumberString(LPTSTR strNumber, int nMaxCount);
|
|
||||||
void ProcessPageShowContextMenu(DWORD dwProcessId);
|
|
||||||
void ProcessPageRefreshThread(void *lpParameter);
|
|
||||||
|
|
||||||
LRESULT CALLBACK ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
RECT rc;
|
|
||||||
int nXDifference;
|
|
||||||
int nYDifference;
|
|
||||||
|
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
case WM_INITDIALOG:
|
|
||||||
|
|
||||||
//
|
|
||||||
// Save the width and height
|
|
||||||
//
|
|
||||||
GetClientRect(hDlg, &rc);
|
|
||||||
nProcessPageWidth = rc.right;
|
|
||||||
nProcessPageHeight = rc.bottom;
|
|
||||||
|
|
||||||
// Update window position
|
|
||||||
SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get handles to the controls
|
|
||||||
//
|
|
||||||
hProcessPageListCtrl = GetDlgItem(hDlg, IDC_PROCESSLIST);
|
|
||||||
hProcessPageHeaderCtrl = ListView_GetHeader(hProcessPageListCtrl);
|
|
||||||
hProcessPageEndProcessButton = GetDlgItem(hDlg, IDC_ENDPROCESS);
|
|
||||||
hProcessPageShowAllProcessesButton = GetDlgItem(hDlg, IDC_SHOWALLPROCESSES);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Set the font, title, and extended window styles for the list control
|
|
||||||
//
|
|
||||||
SendMessage(hProcessPageListCtrl, WM_SETFONT, SendMessage(hProcessPage, WM_GETFONT, 0, 0), TRUE);
|
|
||||||
SetWindowText(hProcessPageListCtrl, "Processes");
|
|
||||||
ListView_SetExtendedListViewStyle(hProcessPageListCtrl, ListView_GetExtendedListViewStyle(hProcessPageListCtrl) | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP);
|
|
||||||
|
|
||||||
AddColumns();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Subclass the process list control so we can intercept WM_ERASEBKGND
|
|
||||||
//
|
|
||||||
OldProcessListWndProc = SetWindowLong(hProcessPageListCtrl, GWL_WNDPROC, (LONG)ProcessListWndProc);
|
|
||||||
|
|
||||||
// Start our refresh thread
|
|
||||||
_beginthread(ProcessPageRefreshThread, 0, NULL);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case WM_DESTROY:
|
|
||||||
// Close the event handle, this will make the
|
|
||||||
// refresh thread exit when the wait fails
|
|
||||||
CloseHandle(hProcessPageEvent);
|
|
||||||
|
|
||||||
SaveColumnSettings();
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_COMMAND:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_SIZE:
|
|
||||||
int cx, cy;
|
|
||||||
|
|
||||||
if (wParam == SIZE_MINIMIZED)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
cx = LOWORD(lParam);
|
|
||||||
cy = HIWORD(lParam);
|
|
||||||
nXDifference = cx - nProcessPageWidth;
|
|
||||||
nYDifference = cy - nProcessPageHeight;
|
|
||||||
nProcessPageWidth = cx;
|
|
||||||
nProcessPageHeight = cy;
|
|
||||||
|
|
||||||
// Reposition the application page's controls
|
|
||||||
GetWindowRect(hProcessPageListCtrl, &rc);
|
|
||||||
cx = (rc.right - rc.left) + nXDifference;
|
|
||||||
cy = (rc.bottom - rc.top) + nYDifference;
|
|
||||||
SetWindowPos(hProcessPageListCtrl, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER);
|
|
||||||
InvalidateRect(hProcessPageListCtrl, NULL, TRUE);
|
|
||||||
|
|
||||||
GetClientRect(hProcessPageEndProcessButton, &rc);
|
|
||||||
MapWindowPoints(hProcessPageEndProcessButton, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) );
|
|
||||||
cx = rc.left + nXDifference;
|
|
||||||
cy = rc.top + nYDifference;
|
|
||||||
SetWindowPos(hProcessPageEndProcessButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
|
||||||
InvalidateRect(hProcessPageEndProcessButton, NULL, TRUE);
|
|
||||||
|
|
||||||
GetClientRect(hProcessPageShowAllProcessesButton, &rc);
|
|
||||||
MapWindowPoints(hProcessPageShowAllProcessesButton, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) );
|
|
||||||
cx = rc.left;
|
|
||||||
cy = rc.top + nYDifference;
|
|
||||||
SetWindowPos(hProcessPageShowAllProcessesButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
|
||||||
InvalidateRect(hProcessPageShowAllProcessesButton, NULL, TRUE);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_NOTIFY:
|
|
||||||
|
|
||||||
ProcessPageOnNotify(wParam, lParam);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
int idctrl;
|
|
||||||
LPNMHDR pnmh;
|
|
||||||
LPNMLISTVIEW pnmv;
|
|
||||||
NMLVDISPINFO* pnmdi;
|
|
||||||
LPNMHEADER pnmhdr;
|
|
||||||
LVITEM lvitem;
|
|
||||||
ULONG Index;
|
|
||||||
ULONG ColumnIndex;
|
|
||||||
IO_COUNTERS iocounters;
|
|
||||||
TIME time;
|
|
||||||
|
|
||||||
idctrl = (int) wParam;
|
|
||||||
pnmh = (LPNMHDR) lParam;
|
|
||||||
pnmv = (LPNMLISTVIEW) lParam;
|
|
||||||
pnmdi = (NMLVDISPINFO*) lParam;
|
|
||||||
pnmhdr = (LPNMHEADER) lParam;
|
|
||||||
|
|
||||||
if (pnmh->hwndFrom == hProcessPageListCtrl)
|
|
||||||
{
|
|
||||||
switch (pnmh->code)
|
|
||||||
{
|
|
||||||
/*case LVN_ITEMCHANGED:
|
|
||||||
ProcessPageUpdate();
|
|
||||||
break;*/
|
|
||||||
|
|
||||||
case LVN_GETDISPINFO:
|
|
||||||
|
|
||||||
if (!(pnmdi->item.mask & LVIF_TEXT))
|
|
||||||
break;
|
|
||||||
|
|
||||||
ColumnIndex = pnmdi->item.iSubItem;
|
|
||||||
Index = pnmdi->item.iItem;
|
|
||||||
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_IMAGENAME)
|
|
||||||
PerfDataGetImageName(Index, pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_PID)
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetProcessId(Index));
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_USERNAME)
|
|
||||||
PerfDataGetUserName(Index, pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_SESSIONID)
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetSessionId(Index));
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_CPUUSAGE)
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%02d"), PerfDataGetCPUUsage(Index));
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_CPUTIME)
|
|
||||||
{
|
|
||||||
time = PerfDataGetCPUTime(Index);
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
DWORD dwHours = (DWORD)(time.QuadPart / 36000000000L);
|
|
||||||
DWORD dwMinutes = (DWORD)((time.QuadPart % 36000000000L) / 600000000L);
|
|
||||||
DWORD dwSeconds = (DWORD)(((time.QuadPart % 36000000000L) % 600000000L) / 10000000L);
|
|
||||||
#else
|
|
||||||
DWORD dwHours = (DWORD)(time.QuadPart / 36000000000LL);
|
|
||||||
DWORD dwMinutes = (DWORD)((time.QuadPart % 36000000000LL) / 600000000LL);
|
|
||||||
DWORD dwSeconds = (DWORD)(((time.QuadPart % 36000000000LL) % 600000000LL) / 10000000LL);
|
|
||||||
#endif
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%d:%02d:%02d"), dwHours, dwMinutes, dwSeconds);
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGE)
|
|
||||||
{
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetWorkingSetSizeBytes(Index) / 1024);
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
_tcscat(pnmdi->item.pszText, _T(" K"));
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_PEAKMEMORYUSAGE)
|
|
||||||
{
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPeakWorkingSetSizeBytes(Index) / 1024);
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
_tcscat(pnmdi->item.pszText, _T(" K"));
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGEDELTA)
|
|
||||||
{
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetWorkingSetSizeDelta(Index) / 1024);
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
_tcscat(pnmdi->item.pszText, _T(" K"));
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTS)
|
|
||||||
{
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPageFaultCount(Index));
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTSDELTA)
|
|
||||||
{
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPageFaultCountDelta(Index));
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_VIRTUALMEMORYSIZE)
|
|
||||||
{
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetVirtualMemorySizeBytes(Index) / 1024);
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
_tcscat(pnmdi->item.pszText, _T(" K"));
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEDPOOL)
|
|
||||||
{
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPagedPoolUsagePages(Index) / 1024);
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
_tcscat(pnmdi->item.pszText, _T(" K"));
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_NONPAGEDPOOL)
|
|
||||||
{
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetNonPagedPoolUsagePages(Index) / 1024);
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
_tcscat(pnmdi->item.pszText, _T(" K"));
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_BASEPRIORITY)
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetBasePriority(Index));
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_HANDLECOUNT)
|
|
||||||
{
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetHandleCount(Index));
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_THREADCOUNT)
|
|
||||||
{
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetThreadCount(Index));
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_USEROBJECTS)
|
|
||||||
{
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetUSERObjectCount(Index));
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_GDIOBJECTS)
|
|
||||||
{
|
|
||||||
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetGDIObjectCount(Index));
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADS)
|
|
||||||
{
|
|
||||||
PerfDataGetIOCounters(Index, &iocounters);
|
|
||||||
//wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.ReadOperationCount);
|
|
||||||
_ui64toa(iocounters.ReadOperationCount, pnmdi->item.pszText, 10);
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITES)
|
|
||||||
{
|
|
||||||
PerfDataGetIOCounters(Index, &iocounters);
|
|
||||||
//wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.WriteOperationCount);
|
|
||||||
_ui64toa(iocounters.WriteOperationCount, pnmdi->item.pszText, 10);
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHER)
|
|
||||||
{
|
|
||||||
PerfDataGetIOCounters(Index, &iocounters);
|
|
||||||
//wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.OtherOperationCount);
|
|
||||||
_ui64toa(iocounters.OtherOperationCount, pnmdi->item.pszText, 10);
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADBYTES)
|
|
||||||
{
|
|
||||||
PerfDataGetIOCounters(Index, &iocounters);
|
|
||||||
//wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.ReadTransferCount);
|
|
||||||
_ui64toa(iocounters.ReadTransferCount, pnmdi->item.pszText, 10);
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITEBYTES)
|
|
||||||
{
|
|
||||||
PerfDataGetIOCounters(Index, &iocounters);
|
|
||||||
//wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.WriteTransferCount);
|
|
||||||
_ui64toa(iocounters.WriteTransferCount, pnmdi->item.pszText, 10);
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
}
|
|
||||||
if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHERBYTES)
|
|
||||||
{
|
|
||||||
PerfDataGetIOCounters(Index, &iocounters);
|
|
||||||
//wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.OtherTransferCount);
|
|
||||||
_ui64toa(iocounters.OtherTransferCount, pnmdi->item.pszText, 10);
|
|
||||||
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NM_RCLICK:
|
|
||||||
|
|
||||||
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
|
|
||||||
{
|
|
||||||
memset(&lvitem, 0, sizeof(LVITEM));
|
|
||||||
|
|
||||||
lvitem.mask = LVIF_STATE;
|
|
||||||
lvitem.stateMask = LVIS_SELECTED;
|
|
||||||
lvitem.iItem = Index;
|
|
||||||
|
|
||||||
ListView_GetItem(hProcessPageListCtrl, &lvitem);
|
|
||||||
|
|
||||||
if (lvitem.state & LVIS_SELECTED)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ListView_GetSelectedCount(hProcessPageListCtrl) == 1) &&
|
|
||||||
(PerfDataGetProcessId(Index) != 0))
|
|
||||||
{
|
|
||||||
ProcessPageShowContextMenu(PerfDataGetProcessId(Index));
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (pnmh->hwndFrom == hProcessPageHeaderCtrl)
|
|
||||||
{
|
|
||||||
switch (pnmh->code)
|
|
||||||
{
|
|
||||||
case HDN_ITEMCLICK:
|
|
||||||
|
|
||||||
//
|
|
||||||
// FIXME: Fix the column sorting
|
|
||||||
//
|
|
||||||
//ListView_SortItems(hApplicationPageListCtrl, ApplicationPageCompareFunc, NULL);
|
|
||||||
//bSortAscending = !bSortAscending;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HDN_ITEMCHANGED:
|
|
||||||
|
|
||||||
UpdateColumnDataHints();
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HDN_ENDDRAG:
|
|
||||||
|
|
||||||
UpdateColumnDataHints();
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommaSeparateNumberString(LPTSTR strNumber, int nMaxCount)
|
|
||||||
{
|
|
||||||
TCHAR temp[260];
|
|
||||||
UINT i, j, k;
|
|
||||||
|
|
||||||
for (i=0,j=0; i<(_tcslen(strNumber) % 3); i++, j++)
|
|
||||||
temp[j] = strNumber[i];
|
|
||||||
|
|
||||||
for (k=0; i<_tcslen(strNumber); i++,j++,k++)
|
|
||||||
{
|
|
||||||
if ((k % 3 == 0) && (j > 0))
|
|
||||||
temp[j++] = _T(',');
|
|
||||||
|
|
||||||
temp[j] = strNumber[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
temp[j] = _T('\0');
|
|
||||||
|
|
||||||
_tcsncpy(strNumber, temp, nMaxCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessPageShowContextMenu(DWORD dwProcessId)
|
|
||||||
{
|
|
||||||
HMENU hMenu;
|
|
||||||
HMENU hSubMenu;
|
|
||||||
HMENU hPriorityMenu;
|
|
||||||
POINT pt;
|
|
||||||
SYSTEM_INFO si;
|
|
||||||
HANDLE hProcess;
|
|
||||||
DWORD dwProcessPriorityClass;
|
|
||||||
TCHAR strDebugger[260];
|
|
||||||
DWORD dwDebuggerSize;
|
|
||||||
HKEY hKey;
|
|
||||||
UINT Idx;
|
|
||||||
|
|
||||||
memset(&si, 0, sizeof(SYSTEM_INFO));
|
|
||||||
|
|
||||||
GetCursorPos(&pt);
|
|
||||||
GetSystemInfo(&si);
|
|
||||||
|
|
||||||
hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PROCESS_PAGE_CONTEXT));
|
|
||||||
hSubMenu = GetSubMenu(hMenu, 0);
|
|
||||||
hPriorityMenu = GetSubMenu(hSubMenu, 4);
|
|
||||||
|
|
||||||
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dwProcessId);
|
|
||||||
dwProcessPriorityClass = GetPriorityClass(hProcess);
|
|
||||||
CloseHandle(hProcess);
|
|
||||||
|
|
||||||
if (si.dwNumberOfProcessors < 2)
|
|
||||||
RemoveMenu(hSubMenu, ID_PROCESS_PAGE_SETAFFINITY, MF_BYCOMMAND);
|
|
||||||
|
|
||||||
switch (dwProcessPriorityClass)
|
|
||||||
{
|
|
||||||
case REALTIME_PRIORITY_CLASS:
|
|
||||||
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, MF_BYCOMMAND);
|
|
||||||
break;
|
|
||||||
case HIGH_PRIORITY_CLASS:
|
|
||||||
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_HIGH, MF_BYCOMMAND);
|
|
||||||
break;
|
|
||||||
case ABOVE_NORMAL_PRIORITY_CLASS:
|
|
||||||
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL, MF_BYCOMMAND);
|
|
||||||
break;
|
|
||||||
case NORMAL_PRIORITY_CLASS:
|
|
||||||
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_NORMAL, MF_BYCOMMAND);
|
|
||||||
break;
|
|
||||||
case BELOW_NORMAL_PRIORITY_CLASS:
|
|
||||||
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL, MF_BYCOMMAND);
|
|
||||||
break;
|
|
||||||
case IDLE_PRIORITY_CLASS:
|
|
||||||
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_LOW, MF_BYCOMMAND);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
dwDebuggerSize = 260;
|
|
||||||
if (RegQueryValueEx(hKey, "Debugger", NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
for (Idx=0; Idx<strlen(strDebugger); Idx++)
|
|
||||||
strDebugger[Idx] = toupper(strDebugger[Idx]);
|
|
||||||
|
|
||||||
if (strstr(strDebugger, "DRWTSN32"))
|
|
||||||
EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
|
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
|
|
||||||
|
|
||||||
TrackPopupMenu(hSubMenu, TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON, pt.x, pt.y, 0, hMainWnd, NULL);
|
|
||||||
|
|
||||||
DestroyMenu(hMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RefreshProcessPage(void)
|
|
||||||
{
|
|
||||||
// Signal the event so that our refresh thread
|
|
||||||
// will wake up and refresh the process page
|
|
||||||
SetEvent(hProcessPageEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessPageRefreshThread(void *lpParameter)
|
|
||||||
{
|
|
||||||
ULONG OldProcessorUsage = 0;
|
|
||||||
ULONG OldProcessCount = 0;
|
|
||||||
|
|
||||||
// Create the event
|
|
||||||
hProcessPageEvent = CreateEvent(NULL, TRUE, TRUE, "Process Page Event");
|
|
||||||
|
|
||||||
// If we couldn't create the event then exit the thread
|
|
||||||
if (!hProcessPageEvent)
|
|
||||||
return;
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
DWORD dwWaitVal;
|
|
||||||
|
|
||||||
// Wait on the event
|
|
||||||
dwWaitVal = WaitForSingleObject(hProcessPageEvent, INFINITE);
|
|
||||||
|
|
||||||
// If the wait failed then the event object must have been
|
|
||||||
// closed and the task manager is exiting so exit this thread
|
|
||||||
if (dwWaitVal == WAIT_FAILED)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (dwWaitVal == WAIT_OBJECT_0)
|
|
||||||
{
|
|
||||||
// Reset our event
|
|
||||||
ResetEvent(hProcessPageEvent);
|
|
||||||
|
|
||||||
if ((ULONG)SendMessage(hProcessPageListCtrl, LVM_GETITEMCOUNT, 0, 0) != PerfDataGetProcessCount())
|
|
||||||
SendMessage(hProcessPageListCtrl, LVM_SETITEMCOUNT, PerfDataGetProcessCount(), /*LVSICF_NOINVALIDATEALL|*/LVSICF_NOSCROLL);
|
|
||||||
|
|
||||||
if (IsWindowVisible(hProcessPage))
|
|
||||||
InvalidateRect(hProcessPageListCtrl, NULL, FALSE);
|
|
||||||
|
|
||||||
TCHAR text[260];
|
|
||||||
|
|
||||||
if (OldProcessorUsage != PerfDataGetProcessorUsage())
|
|
||||||
{
|
|
||||||
OldProcessorUsage = PerfDataGetProcessorUsage();
|
|
||||||
wsprintf(text, _T("CPU Usage: %3d%%"), OldProcessorUsage);
|
|
||||||
SendMessage(hStatusWnd, SB_SETTEXT, 1, (LPARAM)text);
|
|
||||||
}
|
|
||||||
if (OldProcessCount != PerfDataGetProcessCount())
|
|
||||||
{
|
|
||||||
OldProcessCount = PerfDataGetProcessCount();
|
|
||||||
wsprintf(text, _T("Processes: %d"), OldProcessCount);
|
|
||||||
SendMessage(hStatusWnd, SB_SETTEXT, 0, (LPARAM)text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* processpage.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __PROCESSPAGE_H
|
|
||||||
#define __PROCESSPAGE_H
|
|
||||||
|
|
||||||
extern HWND hProcessPage; // Process List Property Page
|
|
||||||
extern HWND hProcessPageListCtrl; // Process ListCtrl Window
|
|
||||||
extern HWND hProcessPageHeaderCtrl; // Process Header Control
|
|
||||||
extern HWND hProcessPageEndProcessButton; // Process End Process button
|
|
||||||
extern HWND hProcessPageShowAllProcessesButton; // Process Show All Processes checkbox
|
|
||||||
|
|
||||||
LRESULT CALLBACK ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
|
||||||
void RefreshProcessPage(void);
|
|
||||||
|
|
||||||
#endif // __PROCESSPAGE_H
|
|
|
@ -1,30 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* stdafx.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// stdafx.cpp : source file that includes just the standard includes
|
|
||||||
// TASKMGR.pch will be the pre-compiled header
|
|
||||||
// stdafx.obj will contain the pre-compiled type information
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
|
|
||||||
// TODO: reference any additional headers you need in STDAFX.H
|
|
||||||
// and not in this file
|
|
|
@ -1,57 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* stdafx.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// stdafx.h : include file for standard system include files,
|
|
||||||
// or project specific include files that are used frequently, but
|
|
||||||
// are changed infrequently
|
|
||||||
//
|
|
||||||
|
|
||||||
#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
|
|
||||||
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
|
|
||||||
|
|
||||||
#if _MSC_VER > 1000
|
|
||||||
#pragma once
|
|
||||||
#endif // _MSC_VER > 1000
|
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
|
|
||||||
// Windows Header Files:
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
//#include <vdmdbg.h>
|
|
||||||
|
|
||||||
// C RunTime Header Files
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
// Local Header Files
|
|
||||||
|
|
||||||
// TODO: reference additional headers your program requires here
|
|
||||||
|
|
||||||
//{{AFX_INSERT_LOCATION}}
|
|
||||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
|
||||||
|
|
||||||
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,79 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* about.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include "stdafx.h"
|
|
||||||
#else
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "taskmgr.h"
|
|
||||||
#include "about.h"
|
|
||||||
|
|
||||||
|
|
||||||
LRESULT CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
|
||||||
|
|
||||||
void OnAbout(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hMainWnd, (DLGPROC)AboutDialogWndProc);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
HWND hLicenseEditWnd;
|
|
||||||
TCHAR strLicense[0x1000];
|
|
||||||
|
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
case WM_INITDIALOG:
|
|
||||||
|
|
||||||
hLicenseEditWnd = GetDlgItem(hDlg, IDC_LICENSE_EDIT);
|
|
||||||
|
|
||||||
LoadString(hInst, IDS_LICENSE, strLicense, 0x1000);
|
|
||||||
|
|
||||||
SetWindowText(hLicenseEditWnd, strLicense);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case WM_COMMAND:
|
|
||||||
|
|
||||||
if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
|
|
||||||
{
|
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,368 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* affinity.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include "stdafx.h"
|
|
||||||
#else
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "taskmgr.h"
|
|
||||||
#include "ProcessPage.h"
|
|
||||||
#include "affinity.h"
|
|
||||||
#include "perfdata.h"
|
|
||||||
|
|
||||||
HANDLE hProcessAffinityHandle;
|
|
||||||
|
|
||||||
LRESULT CALLBACK AffinityDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
|
||||||
|
|
||||||
void ProcessPage_OnSetAffinity(void)
|
|
||||||
{
|
|
||||||
LV_ITEM lvitem;
|
|
||||||
ULONG Index;
|
|
||||||
DWORD dwProcessId;
|
|
||||||
TCHAR strErrorText[260];
|
|
||||||
|
|
||||||
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
|
|
||||||
{
|
|
||||||
memset(&lvitem, 0, sizeof(LV_ITEM));
|
|
||||||
|
|
||||||
lvitem.mask = LVIF_STATE;
|
|
||||||
lvitem.stateMask = LVIS_SELECTED;
|
|
||||||
lvitem.iItem = Index;
|
|
||||||
|
|
||||||
ListView_GetItem(hProcessPageListCtrl, &lvitem);
|
|
||||||
|
|
||||||
if (lvitem.state & LVIS_SELECTED)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwProcessId = PerfDataGetProcessId(Index);
|
|
||||||
|
|
||||||
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
hProcessAffinityHandle = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION, FALSE, dwProcessId);
|
|
||||||
|
|
||||||
if (!hProcessAffinityHandle)
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Access or Set Process Affinity", MB_OK|MB_ICONSTOP);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_AFFINITY_DIALOG), hMainWnd, (DLGPROC)AffinityDialogWndProc);
|
|
||||||
|
|
||||||
if (hProcessAffinityHandle)
|
|
||||||
{
|
|
||||||
CloseHandle(hProcessAffinityHandle);
|
|
||||||
hProcessAffinityHandle = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CALLBACK AffinityDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
DWORD dwProcessAffinityMask = 0;
|
|
||||||
DWORD dwSystemAffinityMask = 0;
|
|
||||||
TCHAR strErrorText[260];
|
|
||||||
|
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
case WM_INITDIALOG:
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get the current affinity mask for the process and
|
|
||||||
// the number of CPUs present in the system
|
|
||||||
//
|
|
||||||
if (!GetProcessAffinityMask(hProcessAffinityHandle, &dwProcessAffinityMask, &dwSystemAffinityMask))
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
EndDialog(hDlg, 0);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Access or Set Process Affinity", MB_OK|MB_ICONSTOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Enable a checkbox for each processor present in the system
|
|
||||||
//
|
|
||||||
if (dwSystemAffinityMask & 0x00000001)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU0), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00000002)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU1), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00000004)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU2), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00000008)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU3), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00000010)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU4), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00000020)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU5), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00000040)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU6), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00000080)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU7), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00000100)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU8), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00000200)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU9), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00000400)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU10), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00000800)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU11), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00001000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU12), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00002000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU13), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00004000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU14), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00008000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU15), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00010000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU16), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00020000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU17), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00040000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU18), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00080000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU19), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00100000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU20), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00200000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU21), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00400000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU22), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x00800000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU23), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x01000000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU24), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x02000000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU25), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x04000000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU26), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x08000000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU27), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x10000000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU28), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x20000000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU29), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x40000000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU30), TRUE);
|
|
||||||
if (dwSystemAffinityMask & 0x80000000)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CPU31), TRUE);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check each checkbox that the current process
|
|
||||||
// has affinity with
|
|
||||||
//
|
|
||||||
if (dwProcessAffinityMask & 0x00000001)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU0), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00000002)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU1), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00000004)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU2), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00000008)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU3), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00000010)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU4), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00000020)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU5), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00000040)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU6), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00000080)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU7), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00000100)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU8), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00000200)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU9), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00000400)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU10), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00000800)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU11), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00001000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU12), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00002000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU13), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00004000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU14), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00008000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU15), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00010000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU16), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00020000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU17), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00040000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU18), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00080000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU19), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00100000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU20), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00200000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU21), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00400000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU22), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x00800000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU23), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x01000000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU24), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x02000000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU25), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x04000000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU26), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x08000000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU27), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x10000000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU28), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x20000000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU29), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x40000000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU30), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (dwProcessAffinityMask & 0x80000000)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPU31), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case WM_COMMAND:
|
|
||||||
|
|
||||||
//
|
|
||||||
// If the user has cancelled the dialog box
|
|
||||||
// then just close it
|
|
||||||
//
|
|
||||||
if (LOWORD(wParam) == IDCANCEL)
|
|
||||||
{
|
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// The user has clicked OK -- so now we have
|
|
||||||
// to adjust the process affinity mask
|
|
||||||
//
|
|
||||||
if (LOWORD(wParam) == IDOK)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// First we have to create a mask out of each
|
|
||||||
// checkbox that the user checked.
|
|
||||||
//
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU0), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00000001;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU1), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00000002;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU2), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00000004;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU3), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00000008;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU4), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00000010;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU5), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00000020;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU6), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00000040;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU7), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00000080;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU8), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00000100;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU9), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00000200;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU10), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00000400;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU11), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00000800;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU12), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00001000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU13), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00002000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU14), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00004000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU15), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00008000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU16), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00010000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU17), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00020000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU18), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00040000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU19), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00080000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU20), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00100000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU21), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00200000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU22), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00400000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU23), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x00800000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU24), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x01000000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU25), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x02000000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU26), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x04000000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU27), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x08000000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU28), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x10000000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU29), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x20000000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU30), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x40000000;
|
|
||||||
if (SendMessage(GetDlgItem(hDlg, IDC_CPU31), BM_GETCHECK, 0, 0))
|
|
||||||
dwProcessAffinityMask |= 0x80000000;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Make sure they are giving the process affinity
|
|
||||||
// with at least one processor. I'd hate to see a
|
|
||||||
// process that is not in a wait state get deprived
|
|
||||||
// of it's cpu time.
|
|
||||||
//
|
|
||||||
if (!dwProcessAffinityMask)
|
|
||||||
{
|
|
||||||
MessageBox(hDlg, "The process must have affinity with at least one processor.", "Invalid Option", MB_OK|MB_ICONSTOP);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Try to set the process affinity
|
|
||||||
//
|
|
||||||
if (!SetProcessAffinityMask(hProcessAffinityHandle, dwProcessAffinityMask))
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Access or Set Process Affinity", MB_OK|MB_ICONSTOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,552 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* column.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include "stdafx.h"
|
|
||||||
#else
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "taskmgr.h"
|
|
||||||
#include "column.h"
|
|
||||||
#include "ProcessPage.h"
|
|
||||||
|
|
||||||
UINT ColumnDataHints[25];
|
|
||||||
|
|
||||||
int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem);
|
|
||||||
LRESULT CALLBACK ColumnsDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
|
||||||
|
|
||||||
void AddColumns(void)
|
|
||||||
{
|
|
||||||
int size;
|
|
||||||
|
|
||||||
if (TaskManagerSettings.Column_ImageName)
|
|
||||||
InsertColumn(0, "Image Name", LVCFMT_LEFT, TaskManagerSettings.ColumnSizeArray[0], -1);
|
|
||||||
if (TaskManagerSettings.Column_PID)
|
|
||||||
InsertColumn(1, "PID", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[1], -1);
|
|
||||||
if (TaskManagerSettings.Column_UserName)
|
|
||||||
InsertColumn(2, "Username", LVCFMT_LEFT, TaskManagerSettings.ColumnSizeArray[2], -1);
|
|
||||||
if (TaskManagerSettings.Column_SessionID)
|
|
||||||
InsertColumn(3, "Session ID", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[3], -1);
|
|
||||||
if (TaskManagerSettings.Column_CPUUsage)
|
|
||||||
InsertColumn(4, "CPU", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[4], -1);
|
|
||||||
if (TaskManagerSettings.Column_CPUTime)
|
|
||||||
InsertColumn(5, "CPU Time", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[5], -1);
|
|
||||||
if (TaskManagerSettings.Column_MemoryUsage)
|
|
||||||
InsertColumn(6, "Mem Usage", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[6], -1);
|
|
||||||
if (TaskManagerSettings.Column_PeakMemoryUsage)
|
|
||||||
InsertColumn(7, "Peak Mem Usage", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[7], -1);
|
|
||||||
if (TaskManagerSettings.Column_MemoryUsageDelta)
|
|
||||||
InsertColumn(8, "Mem Delta", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[8], -1);
|
|
||||||
if (TaskManagerSettings.Column_PageFaults)
|
|
||||||
InsertColumn(9, "Page Faults", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[9], -1);
|
|
||||||
if (TaskManagerSettings.Column_PageFaultsDelta)
|
|
||||||
InsertColumn(10, "PF Delta", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[10], -1);
|
|
||||||
if (TaskManagerSettings.Column_VirtualMemorySize)
|
|
||||||
InsertColumn(11, "VM Size", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[11], -1);
|
|
||||||
if (TaskManagerSettings.Column_PagedPool)
|
|
||||||
InsertColumn(12, "Paged Pool", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[12], -1);
|
|
||||||
if (TaskManagerSettings.Column_NonPagedPool)
|
|
||||||
InsertColumn(13, "NP Pool", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[13], -1);
|
|
||||||
if (TaskManagerSettings.Column_BasePriority)
|
|
||||||
InsertColumn(14, "Base Pri", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[14], -1);
|
|
||||||
if (TaskManagerSettings.Column_HandleCount)
|
|
||||||
InsertColumn(15, "Handles", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[15], -1);
|
|
||||||
if (TaskManagerSettings.Column_ThreadCount)
|
|
||||||
InsertColumn(16, "Threads", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[16], -1);
|
|
||||||
if (TaskManagerSettings.Column_USERObjects)
|
|
||||||
InsertColumn(17, "USER Objects", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[17], -1);
|
|
||||||
if (TaskManagerSettings.Column_GDIObjects)
|
|
||||||
InsertColumn(18, "GDI Objects", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[18], -1);
|
|
||||||
if (TaskManagerSettings.Column_IOReads)
|
|
||||||
InsertColumn(19, "I/O Reads", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[19], -1);
|
|
||||||
if (TaskManagerSettings.Column_IOWrites)
|
|
||||||
InsertColumn(20, "I/O Writes", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[20], -1);
|
|
||||||
if (TaskManagerSettings.Column_IOOther)
|
|
||||||
InsertColumn(21, "I/O Other", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[21], -1);
|
|
||||||
if (TaskManagerSettings.Column_IOReadBytes)
|
|
||||||
InsertColumn(22, "I/O Read Bytes", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[22], -1);
|
|
||||||
if (TaskManagerSettings.Column_IOWriteBytes)
|
|
||||||
InsertColumn(23, "I/O Write Bytes", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[23], -1);
|
|
||||||
if (TaskManagerSettings.Column_IOOtherBytes)
|
|
||||||
InsertColumn(24, "I/O Other Bytes", LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[24], -1);
|
|
||||||
|
|
||||||
size = SendMessage(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0);
|
|
||||||
SendMessage(hProcessPageHeaderCtrl, HDM_SETORDERARRAY, (WPARAM) size, (LPARAM) &TaskManagerSettings.ColumnOrderArray);
|
|
||||||
|
|
||||||
UpdateColumnDataHints();
|
|
||||||
}
|
|
||||||
|
|
||||||
int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem)
|
|
||||||
{
|
|
||||||
LVCOLUMN column;
|
|
||||||
|
|
||||||
column.mask = LVCF_TEXT|LVCF_FMT;
|
|
||||||
column.pszText = (LPTSTR)lpszColumnHeading;
|
|
||||||
column.fmt = nFormat;
|
|
||||||
|
|
||||||
if (nWidth != -1)
|
|
||||||
{
|
|
||||||
column.mask |= LVCF_WIDTH;
|
|
||||||
column.cx = nWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nSubItem != -1)
|
|
||||||
{
|
|
||||||
column.mask |= LVCF_SUBITEM;
|
|
||||||
column.iSubItem = nSubItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ListView_InsertColumn(hProcessPageListCtrl, nCol, &column);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SaveColumnSettings(void)
|
|
||||||
{
|
|
||||||
HDITEM hditem;
|
|
||||||
int i;
|
|
||||||
char text[260];
|
|
||||||
int size;
|
|
||||||
|
|
||||||
// Reset column data
|
|
||||||
for (i=0; i<25; i++)
|
|
||||||
TaskManagerSettings.ColumnOrderArray[i] = i;
|
|
||||||
|
|
||||||
TaskManagerSettings.Column_ImageName = FALSE;
|
|
||||||
TaskManagerSettings.Column_PID = FALSE;
|
|
||||||
TaskManagerSettings.Column_CPUUsage = FALSE;
|
|
||||||
TaskManagerSettings.Column_CPUTime = FALSE;
|
|
||||||
TaskManagerSettings.Column_MemoryUsage = FALSE;
|
|
||||||
TaskManagerSettings.Column_MemoryUsageDelta = FALSE;
|
|
||||||
TaskManagerSettings.Column_PeakMemoryUsage = FALSE;
|
|
||||||
TaskManagerSettings.Column_PageFaults = FALSE;
|
|
||||||
TaskManagerSettings.Column_USERObjects = FALSE;
|
|
||||||
TaskManagerSettings.Column_IOReads = FALSE;
|
|
||||||
TaskManagerSettings.Column_IOReadBytes = FALSE;
|
|
||||||
TaskManagerSettings.Column_SessionID = FALSE;
|
|
||||||
TaskManagerSettings.Column_UserName = FALSE;
|
|
||||||
TaskManagerSettings.Column_PageFaultsDelta = FALSE;
|
|
||||||
TaskManagerSettings.Column_VirtualMemorySize = FALSE;
|
|
||||||
TaskManagerSettings.Column_PagedPool = FALSE;
|
|
||||||
TaskManagerSettings.Column_NonPagedPool = FALSE;
|
|
||||||
TaskManagerSettings.Column_BasePriority = FALSE;
|
|
||||||
TaskManagerSettings.Column_HandleCount = FALSE;
|
|
||||||
TaskManagerSettings.Column_ThreadCount = FALSE;
|
|
||||||
TaskManagerSettings.Column_GDIObjects = FALSE;
|
|
||||||
TaskManagerSettings.Column_IOWrites = FALSE;
|
|
||||||
TaskManagerSettings.Column_IOWriteBytes = FALSE;
|
|
||||||
TaskManagerSettings.Column_IOOther = FALSE;
|
|
||||||
TaskManagerSettings.Column_IOOtherBytes = FALSE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[0] = 105;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[1] = 50;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[2] = 107;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[3] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[4] = 35;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[5] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[6] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[7] = 100;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[8] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[9] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[10] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[11] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[12] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[13] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[14] = 60;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[15] = 60;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[16] = 60;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[17] = 60;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[18] = 60;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[19] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[20] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[21] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[22] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[23] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[24] = 70;
|
|
||||||
|
|
||||||
// Get header order
|
|
||||||
size = SendMessage(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0);
|
|
||||||
SendMessage(hProcessPageHeaderCtrl, HDM_GETORDERARRAY, (WPARAM) size, (LPARAM) &TaskManagerSettings.ColumnOrderArray);
|
|
||||||
|
|
||||||
// Get visible columns
|
|
||||||
for (i=0; i<SendMessage(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0); i++)
|
|
||||||
{
|
|
||||||
memset(&hditem, 0, sizeof(HDITEM));
|
|
||||||
|
|
||||||
hditem.mask = HDI_TEXT|HDI_WIDTH;
|
|
||||||
hditem.pszText = text;
|
|
||||||
hditem.cchTextMax = 260;
|
|
||||||
|
|
||||||
SendMessage(hProcessPageHeaderCtrl, HDM_GETITEM, i, (LPARAM) &hditem);
|
|
||||||
|
|
||||||
if (stricmp(text, "Image Name") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_ImageName = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[0] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "PID") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_PID = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[1] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "Username") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_UserName = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[2] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "Session ID") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_SessionID = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[3] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "CPU") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_CPUUsage = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[4] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "CPU Time") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_CPUTime = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[5] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "Mem Usage") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_MemoryUsage = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[6] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "Peak Mem Usage") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_PeakMemoryUsage = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[7] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "Mem Delta") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_MemoryUsageDelta = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[8] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "Page Faults") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_PageFaults = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[9] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "PF Delta") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_PageFaultsDelta = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[10] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "VM Size") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_VirtualMemorySize = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[11] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "Paged Pool") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_PagedPool = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[12] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "NP Pool") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_NonPagedPool = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[13] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "Base Pri") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_BasePriority = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[14] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "Handles") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_HandleCount = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[15] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "Threads") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_ThreadCount = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[16] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "USER Objects") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_USERObjects = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[17] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "GDI Objects") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_GDIObjects = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[18] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "I/O Reads") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_IOReads = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[19] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "I/O Writes") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_IOWrites = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[20] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "I/O Other") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_IOOther = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[21] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "I/O Read Bytes") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_IOReadBytes = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[22] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "I/O Write Bytes") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_IOWriteBytes = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[23] = hditem.cxy;
|
|
||||||
}
|
|
||||||
if (stricmp(text, "I/O Other Bytes") == 0)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_IOOtherBytes = TRUE;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[24] = hditem.cxy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessPage_OnViewSelectColumns(void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (DialogBox(hInst, MAKEINTRESOURCE(IDD_COLUMNS_DIALOG), hMainWnd, (DLGPROC)ColumnsDialogWndProc) == IDOK)
|
|
||||||
{
|
|
||||||
for (i=Header_GetItemCount(hProcessPageHeaderCtrl)-1; i>=0; i--)
|
|
||||||
{
|
|
||||||
ListView_DeleteColumn(hProcessPageListCtrl, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=0; i<25; i++)
|
|
||||||
TaskManagerSettings.ColumnOrderArray[i] = i;
|
|
||||||
|
|
||||||
TaskManagerSettings.ColumnSizeArray[0] = 105;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[1] = 50;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[2] = 107;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[3] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[4] = 35;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[5] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[6] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[7] = 100;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[8] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[9] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[10] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[11] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[12] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[13] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[14] = 60;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[15] = 60;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[16] = 60;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[17] = 60;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[18] = 60;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[19] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[20] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[21] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[22] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[23] = 70;
|
|
||||||
TaskManagerSettings.ColumnSizeArray[24] = 70;
|
|
||||||
|
|
||||||
AddColumns();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CALLBACK ColumnsDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
|
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
case WM_INITDIALOG:
|
|
||||||
|
|
||||||
if (TaskManagerSettings.Column_ImageName)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_IMAGENAME), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_PID)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_PID), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_UserName)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_USERNAME), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_SessionID)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_SESSIONID), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_CPUUsage)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPUUSAGE), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_CPUTime)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_CPUTIME), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_MemoryUsage)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGE), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_PeakMemoryUsage)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_PEAKMEMORYUSAGE), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_MemoryUsageDelta)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGEDELTA), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_PageFaults)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTS), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_PageFaultsDelta)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTSDELTA), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_VirtualMemorySize)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_VIRTUALMEMORYSIZE), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_PagedPool)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_PAGEDPOOL), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_NonPagedPool)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_NONPAGEDPOOL), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_BasePriority)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_BASEPRIORITY), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_HandleCount)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_HANDLECOUNT), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_ThreadCount)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_THREADCOUNT), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_USERObjects)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_USEROBJECTS), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_GDIObjects)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_GDIOBJECTS), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_IOReads)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_IOREADS), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_IOWrites)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_IOWRITES), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_IOOther)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_IOOTHER), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_IOReadBytes)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_IOREADBYTES), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_IOWriteBytes)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_IOWRITEBYTES), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (TaskManagerSettings.Column_IOOtherBytes)
|
|
||||||
SendMessage(GetDlgItem(hDlg, IDC_IOOTHERBYTES), BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case WM_COMMAND:
|
|
||||||
|
|
||||||
if (LOWORD(wParam) == IDCANCEL)
|
|
||||||
{
|
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LOWORD(wParam) == IDOK)
|
|
||||||
{
|
|
||||||
TaskManagerSettings.Column_ImageName = SendMessage(GetDlgItem(hDlg, IDC_IMAGENAME), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_PID = SendMessage(GetDlgItem(hDlg, IDC_PID), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_UserName = SendMessage(GetDlgItem(hDlg, IDC_USERNAME), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_SessionID = SendMessage(GetDlgItem(hDlg, IDC_SESSIONID), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_CPUUsage = SendMessage(GetDlgItem(hDlg, IDC_CPUUSAGE), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_CPUTime = SendMessage(GetDlgItem(hDlg, IDC_CPUTIME), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_MemoryUsage = SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGE), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_PeakMemoryUsage = SendMessage(GetDlgItem(hDlg, IDC_PEAKMEMORYUSAGE), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_MemoryUsageDelta = SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGEDELTA), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_PageFaults = SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTS), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_PageFaultsDelta = SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTSDELTA), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_VirtualMemorySize = SendMessage(GetDlgItem(hDlg, IDC_VIRTUALMEMORYSIZE), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_PagedPool = SendMessage(GetDlgItem(hDlg, IDC_PAGEDPOOL), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_NonPagedPool = SendMessage(GetDlgItem(hDlg, IDC_NONPAGEDPOOL), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_BasePriority = SendMessage(GetDlgItem(hDlg, IDC_BASEPRIORITY), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_HandleCount = SendMessage(GetDlgItem(hDlg, IDC_HANDLECOUNT), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_ThreadCount = SendMessage(GetDlgItem(hDlg, IDC_THREADCOUNT), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_USERObjects = SendMessage(GetDlgItem(hDlg, IDC_USEROBJECTS), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_GDIObjects = SendMessage(GetDlgItem(hDlg, IDC_GDIOBJECTS), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_IOReads = SendMessage(GetDlgItem(hDlg, IDC_IOREADS), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_IOWrites = SendMessage(GetDlgItem(hDlg, IDC_IOWRITES), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_IOOther = SendMessage(GetDlgItem(hDlg, IDC_IOOTHER), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_IOReadBytes = SendMessage(GetDlgItem(hDlg, IDC_IOREADBYTES), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_IOWriteBytes = SendMessage(GetDlgItem(hDlg, IDC_IOWRITEBYTES), BM_GETCHECK, 0, 0);
|
|
||||||
TaskManagerSettings.Column_IOOtherBytes = SendMessage(GetDlgItem(hDlg, IDC_IOOTHERBYTES), BM_GETCHECK, 0, 0);
|
|
||||||
|
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateColumnDataHints(void)
|
|
||||||
{
|
|
||||||
HDITEM hditem;
|
|
||||||
TCHAR text[260];
|
|
||||||
ULONG Index;
|
|
||||||
|
|
||||||
for (Index=0; Index<(ULONG)SendMessage(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0); Index++)
|
|
||||||
{
|
|
||||||
memset(&hditem, 0, sizeof(HDITEM));
|
|
||||||
|
|
||||||
hditem.mask = HDI_TEXT;
|
|
||||||
hditem.pszText = text;
|
|
||||||
hditem.cchTextMax = 260;
|
|
||||||
|
|
||||||
SendMessage(hProcessPageHeaderCtrl, HDM_GETITEM, Index, (LPARAM) &hditem);
|
|
||||||
|
|
||||||
if (stricmp(text, "Image Name") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_IMAGENAME;
|
|
||||||
if (stricmp(text, "PID") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_PID;
|
|
||||||
if (stricmp(text, "Username") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_USERNAME;
|
|
||||||
if (stricmp(text, "Session ID") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_SESSIONID;
|
|
||||||
if (stricmp(text, "CPU") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_CPUUSAGE;
|
|
||||||
if (stricmp(text, "CPU Time") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_CPUTIME;
|
|
||||||
if (stricmp(text, "Mem Usage") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_MEMORYUSAGE;
|
|
||||||
if (stricmp(text, "Peak Mem Usage") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_PEAKMEMORYUSAGE;
|
|
||||||
if (stricmp(text, "Mem Delta") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_MEMORYUSAGEDELTA;
|
|
||||||
if (stricmp(text, "Page Faults") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_PAGEFAULTS;
|
|
||||||
if (stricmp(text, "PF Delta") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_PAGEFAULTSDELTA;
|
|
||||||
if (stricmp(text, "VM Size") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_VIRTUALMEMORYSIZE;
|
|
||||||
if (stricmp(text, "Paged Pool") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_PAGEDPOOL;
|
|
||||||
if (stricmp(text, "NP Pool") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_NONPAGEDPOOL;
|
|
||||||
if (stricmp(text, "Base Pri") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_BASEPRIORITY;
|
|
||||||
if (stricmp(text, "Handles") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_HANDLECOUNT;
|
|
||||||
if (stricmp(text, "Threads") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_THREADCOUNT;
|
|
||||||
if (stricmp(text, "USER Objects") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_USEROBJECTS;
|
|
||||||
if (stricmp(text, "GDI Objects") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_GDIOBJECTS;
|
|
||||||
if (stricmp(text, "I/O Reads") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_IOREADS;
|
|
||||||
if (stricmp(text, "I/O Writes") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_IOWRITES;
|
|
||||||
if (stricmp(text, "I/O Other") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_IOOTHER;
|
|
||||||
if (stricmp(text, "I/O Read Bytes") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_IOREADBYTES;
|
|
||||||
if (stricmp(text, "I/O Write Bytes") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_IOWRITEBYTES;
|
|
||||||
if (stricmp(text, "I/O Other Bytes") == 0)
|
|
||||||
ColumnDataHints[Index] = COLUMN_IOOTHERBYTES;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,120 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* debug.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include "stdafx.h"
|
|
||||||
#else
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "taskmgr.h"
|
|
||||||
#include "debug.h"
|
|
||||||
#include "ProcessPage.h"
|
|
||||||
#include "perfdata.h"
|
|
||||||
|
|
||||||
void ProcessPage_OnDebug(void)
|
|
||||||
{
|
|
||||||
LVITEM lvitem;
|
|
||||||
ULONG Index;
|
|
||||||
DWORD dwProcessId;
|
|
||||||
TCHAR strErrorText[260];
|
|
||||||
HKEY hKey;
|
|
||||||
TCHAR strDebugPath[260];
|
|
||||||
TCHAR strDebugger[260];
|
|
||||||
DWORD dwDebuggerSize;
|
|
||||||
PROCESS_INFORMATION pi;
|
|
||||||
STARTUPINFO si;
|
|
||||||
HANDLE hDebugEvent;
|
|
||||||
|
|
||||||
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
|
|
||||||
{
|
|
||||||
memset(&lvitem, 0, sizeof(LVITEM));
|
|
||||||
|
|
||||||
lvitem.mask = LVIF_STATE;
|
|
||||||
lvitem.stateMask = LVIS_SELECTED;
|
|
||||||
lvitem.iItem = Index;
|
|
||||||
|
|
||||||
ListView_GetItem(hProcessPageListCtrl, &lvitem);
|
|
||||||
|
|
||||||
if (lvitem.state & LVIS_SELECTED)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwProcessId = PerfDataGetProcessId(Index);
|
|
||||||
|
|
||||||
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (MessageBox(hMainWnd, "WARNING: Debugging this process may result in loss of data.\nAre you sure you wish to attach the debugger?", "Task Manager Warning", MB_YESNO|MB_ICONWARNING) != IDYES)
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Debug Process", MB_OK|MB_ICONSTOP);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Debug Process", MB_OK|MB_ICONSTOP);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwDebuggerSize = 260;
|
|
||||||
if (RegQueryValueEx(hKey, "Debugger", NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Debug Process", MB_OK|MB_ICONSTOP);
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
|
|
||||||
hDebugEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
|
||||||
if (!hDebugEvent)
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Debug Process", MB_OK|MB_ICONSTOP);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wsprintf(strDebugPath, strDebugger, dwProcessId, hDebugEvent);
|
|
||||||
|
|
||||||
memset(&pi, 0, sizeof(PROCESS_INFORMATION));
|
|
||||||
memset(&si, 0, sizeof(STARTUPINFO));
|
|
||||||
si.cb = sizeof(STARTUPINFO);
|
|
||||||
if (!CreateProcess(NULL, strDebugPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Debug Process", MB_OK|MB_ICONSTOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(hDebugEvent);
|
|
||||||
}
|
|
|
@ -1,136 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* endproc.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include "stdafx.h"
|
|
||||||
#else
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "taskmgr.h"
|
|
||||||
#include "endproc.h"
|
|
||||||
#include "ProcessPage.h"
|
|
||||||
#include "perfdata.h"
|
|
||||||
|
|
||||||
void ProcessPage_OnEndProcess(void)
|
|
||||||
{
|
|
||||||
LVITEM lvitem;
|
|
||||||
ULONG Index;
|
|
||||||
DWORD dwProcessId;
|
|
||||||
HANDLE hProcess;
|
|
||||||
TCHAR strErrorText[260];
|
|
||||||
|
|
||||||
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
|
|
||||||
{
|
|
||||||
memset(&lvitem, 0, sizeof(LVITEM));
|
|
||||||
|
|
||||||
lvitem.mask = LVIF_STATE;
|
|
||||||
lvitem.stateMask = LVIS_SELECTED;
|
|
||||||
lvitem.iItem = Index;
|
|
||||||
|
|
||||||
ListView_GetItem(hProcessPageListCtrl, &lvitem);
|
|
||||||
|
|
||||||
if (lvitem.state & LVIS_SELECTED)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwProcessId = PerfDataGetProcessId(Index);
|
|
||||||
|
|
||||||
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (MessageBox(hMainWnd, "WARNING: Terminating a process can cause undesired\nresults including loss of data and system instability. The\nprocess will not be given the chance to save its state or\ndata before it is terminated. Are you sure you want to\nterminate the process?", "Task Manager Warning", MB_YESNO|MB_ICONWARNING) != IDYES)
|
|
||||||
return;
|
|
||||||
|
|
||||||
hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
|
|
||||||
|
|
||||||
if (!hProcess)
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Terminate Process", MB_OK|MB_ICONSTOP);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TerminateProcess(hProcess, 0))
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Terminate Process", MB_OK|MB_ICONSTOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(hProcess);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessPage_OnEndProcessTree(void)
|
|
||||||
{
|
|
||||||
LVITEM lvitem;
|
|
||||||
ULONG Index;
|
|
||||||
DWORD dwProcessId;
|
|
||||||
HANDLE hProcess;
|
|
||||||
TCHAR strErrorText[260];
|
|
||||||
|
|
||||||
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
|
|
||||||
{
|
|
||||||
memset(&lvitem, 0, sizeof(LVITEM));
|
|
||||||
|
|
||||||
lvitem.mask = LVIF_STATE;
|
|
||||||
lvitem.stateMask = LVIS_SELECTED;
|
|
||||||
lvitem.iItem = Index;
|
|
||||||
|
|
||||||
ListView_GetItem(hProcessPageListCtrl, &lvitem);
|
|
||||||
|
|
||||||
if (lvitem.state & LVIS_SELECTED)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwProcessId = PerfDataGetProcessId(Index);
|
|
||||||
|
|
||||||
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (MessageBox(hMainWnd, "WARNING: Terminating a process can cause undesired\nresults including loss of data and system instability. The\nprocess will not be given the chance to save its state or\ndata before it is terminated. Are you sure you want to\nterminate the process?", "Task Manager Warning", MB_YESNO|MB_ICONWARNING) != IDYES)
|
|
||||||
return;
|
|
||||||
|
|
||||||
hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
|
|
||||||
|
|
||||||
if (!hProcess)
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Terminate Process", MB_OK|MB_ICONSTOP);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TerminateProcess(hProcess, 0))
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Terminate Process", MB_OK|MB_ICONSTOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(hProcess);
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* font.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include "stdafx.h"
|
|
||||||
#else
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "taskmgr.h"
|
|
||||||
#include "font.h"
|
|
||||||
|
|
||||||
void Font_DrawText(HDC hDC, LPCTSTR lpszText, int x, int y)
|
|
||||||
{
|
|
||||||
HDC hFontDC;
|
|
||||||
HBITMAP hFontBitmap;
|
|
||||||
HBITMAP hOldBitmap;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
hFontDC = CreateCompatibleDC(hDC);
|
|
||||||
hFontBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_FONT));
|
|
||||||
hOldBitmap = (HBITMAP)SelectObject(hFontDC, hFontBitmap);
|
|
||||||
|
|
||||||
for (i = 0; i < (int)_tcslen(lpszText); i++) {
|
|
||||||
if ((lpszText[i] >= '0') && (lpszText[i] <= '9')) {
|
|
||||||
BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, (lpszText[i] - '0') * 8, 0, SRCCOPY);
|
|
||||||
}
|
|
||||||
else if (lpszText[i] == 'K')
|
|
||||||
{
|
|
||||||
BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, 80, 0, SRCCOPY);
|
|
||||||
}
|
|
||||||
else if (lpszText[i] == '%')
|
|
||||||
{
|
|
||||||
BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, 88, 0, SRCCOPY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SelectObject(hFontDC, hOldBitmap);
|
|
||||||
DeleteObject(hFontBitmap);
|
|
||||||
DeleteDC(hFontDC);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,471 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* graph.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include "stdafx.h"
|
|
||||||
#else
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "taskmgr.h"
|
|
||||||
#include "graph.h"
|
|
||||||
#include "font.h"
|
|
||||||
#include "perfdata.h"
|
|
||||||
|
|
||||||
|
|
||||||
LONG OldGraphWndProc;
|
|
||||||
|
|
||||||
void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd);
|
|
||||||
void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd);
|
|
||||||
void Graph_DrawMemUsageHistoryGraph(HDC hDC, HWND hWnd);
|
|
||||||
|
|
||||||
LRESULT CALLBACK Graph_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
HDC hdc;
|
|
||||||
PAINTSTRUCT ps;
|
|
||||||
LONG WindowId;
|
|
||||||
|
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
case WM_ERASEBKGND:
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Filter out mouse & keyboard messages
|
|
||||||
//
|
|
||||||
//case WM_APPCOMMAND:
|
|
||||||
case WM_CAPTURECHANGED:
|
|
||||||
case WM_LBUTTONDBLCLK:
|
|
||||||
case WM_LBUTTONDOWN:
|
|
||||||
case WM_LBUTTONUP:
|
|
||||||
case WM_MBUTTONDBLCLK:
|
|
||||||
case WM_MBUTTONDOWN:
|
|
||||||
case WM_MBUTTONUP:
|
|
||||||
case WM_MOUSEACTIVATE:
|
|
||||||
case WM_MOUSEHOVER:
|
|
||||||
case WM_MOUSELEAVE:
|
|
||||||
case WM_MOUSEMOVE:
|
|
||||||
//case WM_MOUSEWHEEL:
|
|
||||||
case WM_NCHITTEST:
|
|
||||||
case WM_NCLBUTTONDBLCLK:
|
|
||||||
case WM_NCLBUTTONDOWN:
|
|
||||||
case WM_NCLBUTTONUP:
|
|
||||||
case WM_NCMBUTTONDBLCLK:
|
|
||||||
case WM_NCMBUTTONDOWN:
|
|
||||||
case WM_NCMBUTTONUP:
|
|
||||||
//case WM_NCMOUSEHOVER:
|
|
||||||
//case WM_NCMOUSELEAVE:
|
|
||||||
case WM_NCMOUSEMOVE:
|
|
||||||
case WM_NCRBUTTONDBLCLK:
|
|
||||||
case WM_NCRBUTTONDOWN:
|
|
||||||
case WM_NCRBUTTONUP:
|
|
||||||
//case WM_NCXBUTTONDBLCLK:
|
|
||||||
//case WM_NCXBUTTONDOWN:
|
|
||||||
//case WM_NCXBUTTONUP:
|
|
||||||
case WM_RBUTTONDBLCLK:
|
|
||||||
case WM_RBUTTONDOWN:
|
|
||||||
case WM_RBUTTONUP:
|
|
||||||
//case WM_XBUTTONDBLCLK:
|
|
||||||
//case WM_XBUTTONDOWN:
|
|
||||||
//case WM_XBUTTONUP:
|
|
||||||
case WM_ACTIVATE:
|
|
||||||
case WM_CHAR:
|
|
||||||
case WM_DEADCHAR:
|
|
||||||
case WM_GETHOTKEY:
|
|
||||||
case WM_HOTKEY:
|
|
||||||
case WM_KEYDOWN:
|
|
||||||
case WM_KEYUP:
|
|
||||||
case WM_KILLFOCUS:
|
|
||||||
case WM_SETFOCUS:
|
|
||||||
case WM_SETHOTKEY:
|
|
||||||
case WM_SYSCHAR:
|
|
||||||
case WM_SYSDEADCHAR:
|
|
||||||
case WM_SYSKEYDOWN:
|
|
||||||
case WM_SYSKEYUP:
|
|
||||||
|
|
||||||
case WM_NCCALCSIZE:
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case WM_PAINT:
|
|
||||||
|
|
||||||
hdc = BeginPaint(hWnd, &ps);
|
|
||||||
|
|
||||||
WindowId = GetWindowLong(hWnd, GWL_ID);
|
|
||||||
|
|
||||||
switch (WindowId)
|
|
||||||
{
|
|
||||||
case IDC_CPU_USAGE_GRAPH:
|
|
||||||
Graph_DrawCpuUsageGraph(hdc, hWnd);
|
|
||||||
break;
|
|
||||||
case IDC_MEM_USAGE_GRAPH:
|
|
||||||
Graph_DrawMemUsageGraph(hdc, hWnd);
|
|
||||||
break;
|
|
||||||
case IDC_MEM_USAGE_HISTORY_GRAPH:
|
|
||||||
Graph_DrawMemUsageHistoryGraph(hdc, hWnd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
EndPaint(hWnd, &ps);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// We pass on all non-handled messages
|
|
||||||
//
|
|
||||||
return CallWindowProc((WNDPROC)OldGraphWndProc, hWnd, message, wParam, lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
|
|
||||||
{
|
|
||||||
RECT rcClient;
|
|
||||||
RECT rcBarLeft;
|
|
||||||
RECT rcBarRight;
|
|
||||||
TCHAR Text[260];
|
|
||||||
ULONG CpuUsage;
|
|
||||||
ULONG CpuKernelUsage;
|
|
||||||
int nBars;
|
|
||||||
int nBarsUsed; // Bottom bars that are "used", i.e. are bright green, representing used cpu time
|
|
||||||
int nBarsUsedKernel; // Bottom bars that are "used", i.e. are bright green, representing used cpu kernel time
|
|
||||||
int nBarsFree; // Top bars that are "unused", i.e. are dark green, representing free cpu time
|
|
||||||
int i;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get the client area rectangle
|
|
||||||
//
|
|
||||||
GetClientRect(hWnd, &rcClient);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Fill it with blackness
|
|
||||||
//
|
|
||||||
FillSolidRect(hDC, &rcClient, RGB(0, 0, 0));
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get the CPU usage
|
|
||||||
//
|
|
||||||
CpuUsage = PerfDataGetProcessorUsage();
|
|
||||||
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
|
|
||||||
if (CpuUsage < 0) CpuUsage = 0;
|
|
||||||
if (CpuUsage > 100) CpuUsage = 100;
|
|
||||||
if (CpuKernelUsage < 0) CpuKernelUsage = 0;
|
|
||||||
if (CpuKernelUsage > 100) CpuKernelUsage = 100;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check and see how many digits it will take
|
|
||||||
// so we get the indentation right every time.
|
|
||||||
//
|
|
||||||
if (CpuUsage == 100)
|
|
||||||
{
|
|
||||||
_stprintf(Text, _T("%d%%"), CpuUsage);
|
|
||||||
}
|
|
||||||
else if (CpuUsage < 10)
|
|
||||||
{
|
|
||||||
_stprintf(Text, _T(" %d%%"), CpuUsage);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_stprintf(Text, _T(" %d%%"), CpuUsage);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw the font text onto the graph
|
|
||||||
// The bottom 20 pixels are reserved for the text
|
|
||||||
//
|
|
||||||
Font_DrawText(hDC, Text, ((rcClient.right - rcClient.left) - 32) / 2, rcClient.bottom - 11 - 5);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Now we have to draw the graph
|
|
||||||
// So first find out how many bars we can fit
|
|
||||||
//
|
|
||||||
nBars = ((rcClient.bottom - rcClient.top) - 25) / 3;
|
|
||||||
nBarsUsed = (nBars * CpuUsage) / 100;
|
|
||||||
if ((CpuUsage) && (nBarsUsed == 0))
|
|
||||||
{
|
|
||||||
nBarsUsed = 1;
|
|
||||||
}
|
|
||||||
nBarsFree = nBars - nBarsUsed;
|
|
||||||
if (TaskManagerSettings.ShowKernelTimes)
|
|
||||||
{
|
|
||||||
nBarsUsedKernel = ((nBars * 2) * CpuKernelUsage) / 100;
|
|
||||||
nBarsUsed -= (nBarsUsedKernel / 2);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nBarsUsedKernel = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Now draw the bar graph
|
|
||||||
//
|
|
||||||
rcBarLeft.left = ((rcClient.right - rcClient.left) - 33) / 2;
|
|
||||||
rcBarLeft.right = rcBarLeft.left + 16;
|
|
||||||
rcBarRight.left = rcBarLeft.left + 17;
|
|
||||||
rcBarRight.right = rcBarLeft.right + 17;
|
|
||||||
rcBarLeft.top = rcBarRight.top = 5;
|
|
||||||
rcBarLeft.bottom = rcBarRight.bottom = 7;
|
|
||||||
|
|
||||||
if (nBarsUsed < 0) nBarsUsed = 0;
|
|
||||||
if (nBarsUsed > nBars) nBarsUsed = nBars;
|
|
||||||
|
|
||||||
if (nBarsFree < 0) nBarsFree = 0;
|
|
||||||
if (nBarsFree > nBars) nBarsFree = nBars;
|
|
||||||
|
|
||||||
if (nBarsUsedKernel < 0) nBarsUsedKernel = 0;
|
|
||||||
if (nBarsUsedKernel > nBars) nBarsUsedKernel = nBars;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw the "free" bars
|
|
||||||
//
|
|
||||||
for (i=0; i<nBarsFree; i++)
|
|
||||||
{
|
|
||||||
FillSolidRect(hDC, &rcBarLeft, DARK_GREEN);
|
|
||||||
FillSolidRect(hDC, &rcBarRight, DARK_GREEN);
|
|
||||||
|
|
||||||
rcBarLeft.top += 3;
|
|
||||||
rcBarLeft.bottom += 3;
|
|
||||||
|
|
||||||
rcBarRight.top += 3;
|
|
||||||
rcBarRight.bottom += 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw the "used" bars
|
|
||||||
//
|
|
||||||
for (i=0; i<nBarsUsed; i++)
|
|
||||||
{
|
|
||||||
if (nBarsUsed > 5000) nBarsUsed = 5000;
|
|
||||||
|
|
||||||
FillSolidRect(hDC, &rcBarLeft, BRIGHT_GREEN);
|
|
||||||
FillSolidRect(hDC, &rcBarRight, BRIGHT_GREEN);
|
|
||||||
|
|
||||||
rcBarLeft.top += 3;
|
|
||||||
rcBarLeft.bottom += 3;
|
|
||||||
|
|
||||||
rcBarRight.top += 3;
|
|
||||||
rcBarRight.bottom += 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw the "used" kernel bars
|
|
||||||
//
|
|
||||||
rcBarLeft.bottom--;
|
|
||||||
rcBarRight.bottom--;
|
|
||||||
if (nBarsUsedKernel && nBarsUsedKernel % 2)
|
|
||||||
{
|
|
||||||
rcBarLeft.top -= 2;
|
|
||||||
rcBarLeft.bottom -= 2;
|
|
||||||
|
|
||||||
rcBarRight.top -= 2;
|
|
||||||
rcBarRight.bottom -= 2;
|
|
||||||
|
|
||||||
FillSolidRect(hDC, &rcBarLeft, RED);
|
|
||||||
FillSolidRect(hDC, &rcBarRight, RED);
|
|
||||||
|
|
||||||
rcBarLeft.top += 2;
|
|
||||||
rcBarLeft.bottom += 2;
|
|
||||||
|
|
||||||
rcBarRight.top += 2;
|
|
||||||
rcBarRight.bottom += 2;
|
|
||||||
|
|
||||||
nBarsUsedKernel--;
|
|
||||||
}
|
|
||||||
for (i=0; i<nBarsUsedKernel; i++)
|
|
||||||
{
|
|
||||||
if (nBarsUsedKernel > 5000) nBarsUsedKernel = 5000;
|
|
||||||
|
|
||||||
FillSolidRect(hDC, &rcBarLeft, RED);
|
|
||||||
FillSolidRect(hDC, &rcBarRight, RED);
|
|
||||||
|
|
||||||
rcBarLeft.top++;
|
|
||||||
rcBarLeft.bottom++;
|
|
||||||
|
|
||||||
rcBarRight.top++;
|
|
||||||
rcBarRight.bottom++;
|
|
||||||
|
|
||||||
if (i % 2)
|
|
||||||
{
|
|
||||||
rcBarLeft.top++;
|
|
||||||
rcBarLeft.bottom++;
|
|
||||||
|
|
||||||
rcBarRight.top++;
|
|
||||||
rcBarRight.bottom++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd)
|
|
||||||
{
|
|
||||||
RECT rcClient;
|
|
||||||
RECT rcBarLeft;
|
|
||||||
RECT rcBarRight;
|
|
||||||
TCHAR Text[260];
|
|
||||||
ULONGLONG CommitChargeTotal;
|
|
||||||
ULONGLONG CommitChargeLimit;
|
|
||||||
int nBars;
|
|
||||||
int nBarsUsed; // Bottom bars that are "used", i.e. are bright green, representing used memory
|
|
||||||
int nBarsFree; // Top bars that are "unused", i.e. are dark green, representing free memory
|
|
||||||
int i;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get the client area rectangle
|
|
||||||
//
|
|
||||||
GetClientRect(hWnd, &rcClient);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Fill it with blackness
|
|
||||||
//
|
|
||||||
FillSolidRect(hDC, &rcClient, RGB(0, 0, 0));
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get the memory usage
|
|
||||||
//
|
|
||||||
CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
|
|
||||||
CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
|
|
||||||
|
|
||||||
_stprintf(Text, _T("%dK"), CommitChargeTotal);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw the font text onto the graph
|
|
||||||
// The bottom 20 pixels are reserved for the text
|
|
||||||
//
|
|
||||||
Font_DrawText(hDC, Text, ((rcClient.right - rcClient.left) - (strlen(Text) * 8)) / 2, rcClient.bottom - 11 - 5);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Now we have to draw the graph
|
|
||||||
// So first find out how many bars we can fit
|
|
||||||
//
|
|
||||||
nBars = ((rcClient.bottom - rcClient.top) - 25) / 3;
|
|
||||||
nBarsUsed = (nBars * (int)((CommitChargeTotal * 100) / CommitChargeLimit)) / 100;
|
|
||||||
nBarsFree = nBars - nBarsUsed;
|
|
||||||
|
|
||||||
if (nBarsUsed < 0) nBarsUsed = 0;
|
|
||||||
if (nBarsUsed > nBars) nBarsUsed = nBars;
|
|
||||||
|
|
||||||
if (nBarsFree < 0) nBarsFree = 0;
|
|
||||||
if (nBarsFree > nBars) nBarsFree = nBars;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Now draw the bar graph
|
|
||||||
//
|
|
||||||
rcBarLeft.left = ((rcClient.right - rcClient.left) - 33) / 2;
|
|
||||||
rcBarLeft.right = rcBarLeft.left + 16;
|
|
||||||
rcBarRight.left = rcBarLeft.left + 17;
|
|
||||||
rcBarRight.right = rcBarLeft.right + 17;
|
|
||||||
rcBarLeft.top = rcBarRight.top = 5;
|
|
||||||
rcBarLeft.bottom = rcBarRight.bottom = 7;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw the "free" bars
|
|
||||||
//
|
|
||||||
for (i=0; i<nBarsFree; i++)
|
|
||||||
{
|
|
||||||
FillSolidRect(hDC, &rcBarLeft, DARK_GREEN);
|
|
||||||
FillSolidRect(hDC, &rcBarRight, DARK_GREEN);
|
|
||||||
|
|
||||||
rcBarLeft.top += 3;
|
|
||||||
rcBarLeft.bottom += 3;
|
|
||||||
|
|
||||||
rcBarRight.top += 3;
|
|
||||||
rcBarRight.bottom += 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw the "used" bars
|
|
||||||
//
|
|
||||||
for (i=0; i<nBarsUsed; i++)
|
|
||||||
{
|
|
||||||
FillSolidRect(hDC, &rcBarLeft, BRIGHT_GREEN);
|
|
||||||
FillSolidRect(hDC, &rcBarRight, BRIGHT_GREEN);
|
|
||||||
|
|
||||||
rcBarLeft.top += 3;
|
|
||||||
rcBarLeft.bottom += 3;
|
|
||||||
|
|
||||||
rcBarRight.top += 3;
|
|
||||||
rcBarRight.bottom += 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Graph_DrawMemUsageHistoryGraph(HDC hDC, HWND hWnd)
|
|
||||||
{
|
|
||||||
RECT rcClient;
|
|
||||||
ULONGLONG CommitChargeLimit;
|
|
||||||
int i;
|
|
||||||
static int offset = 0;
|
|
||||||
|
|
||||||
if (offset++ >= 10)
|
|
||||||
offset = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get the client area rectangle
|
|
||||||
//
|
|
||||||
GetClientRect(hWnd, &rcClient);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Fill it with blackness
|
|
||||||
//
|
|
||||||
FillSolidRect(hDC, &rcClient, RGB(0, 0, 0));
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get the memory usage
|
|
||||||
//
|
|
||||||
CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw the graph background
|
|
||||||
//
|
|
||||||
// Draw the horizontal bars
|
|
||||||
//
|
|
||||||
for (i=0; i<rcClient.bottom; i++)
|
|
||||||
{
|
|
||||||
if ((i % 11) == 0)
|
|
||||||
{
|
|
||||||
FillSolidRect(hDC, 0, i, rcClient.right, 1, DARK_GREEN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Draw the vertical bars
|
|
||||||
//
|
|
||||||
for (i=11; i<rcClient.right + offset; i++)
|
|
||||||
{
|
|
||||||
if ((i % 11) == 0)
|
|
||||||
{
|
|
||||||
FillSolidRect(hDC, i - offset, 0, 1, rcClient.bottom, DARK_GREEN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw the memory usage
|
|
||||||
//
|
|
||||||
for (i=rcClient.right; i>=0; i--)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,154 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* optnmenu.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// options.c
|
|
||||||
//
|
|
||||||
// Menu item handlers for the options menu.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include "stdafx.h"
|
|
||||||
#else
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "taskmgr.h"
|
|
||||||
#include "optnmenu.h"
|
|
||||||
#include "ProcessPage.h"
|
|
||||||
|
|
||||||
#define OPTIONS_MENU_INDEX 1
|
|
||||||
|
|
||||||
void TaskManager_OnOptionsAlwaysOnTop(void)
|
|
||||||
{
|
|
||||||
HMENU hMenu;
|
|
||||||
HMENU hOptionsMenu;
|
|
||||||
|
|
||||||
hMenu = GetMenu(hMainWnd);
|
|
||||||
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check or uncheck the always on top menu item
|
|
||||||
// and update main window.
|
|
||||||
//
|
|
||||||
if (GetMenuState(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND) & MF_CHECKED)
|
|
||||||
{
|
|
||||||
CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_UNCHECKED);
|
|
||||||
TaskManagerSettings.AlwaysOnTop = FALSE;
|
|
||||||
SetWindowPos(hMainWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_CHECKED);
|
|
||||||
TaskManagerSettings.AlwaysOnTop = TRUE;
|
|
||||||
SetWindowPos(hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskManager_OnOptionsMinimizeOnUse(void)
|
|
||||||
{
|
|
||||||
HMENU hMenu;
|
|
||||||
HMENU hOptionsMenu;
|
|
||||||
|
|
||||||
hMenu = GetMenu(hMainWnd);
|
|
||||||
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check or uncheck the minimize on use menu item.
|
|
||||||
//
|
|
||||||
if (GetMenuState(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND) & MF_CHECKED)
|
|
||||||
{
|
|
||||||
CheckMenuItem(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_UNCHECKED);
|
|
||||||
TaskManagerSettings.MinimizeOnUse = FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CheckMenuItem(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_CHECKED);
|
|
||||||
TaskManagerSettings.MinimizeOnUse = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskManager_OnOptionsHideWhenMinimized(void)
|
|
||||||
{
|
|
||||||
HMENU hMenu;
|
|
||||||
HMENU hOptionsMenu;
|
|
||||||
|
|
||||||
hMenu = GetMenu(hMainWnd);
|
|
||||||
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check or uncheck the hide when minimized menu item.
|
|
||||||
//
|
|
||||||
if (GetMenuState(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND) & MF_CHECKED)
|
|
||||||
{
|
|
||||||
CheckMenuItem(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_UNCHECKED);
|
|
||||||
TaskManagerSettings.HideWhenMinimized = FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CheckMenuItem(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_CHECKED);
|
|
||||||
TaskManagerSettings.HideWhenMinimized = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskManager_OnOptionsShow16BitTasks(void)
|
|
||||||
{
|
|
||||||
HMENU hMenu;
|
|
||||||
HMENU hOptionsMenu;
|
|
||||||
|
|
||||||
hMenu = GetMenu(hMainWnd);
|
|
||||||
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
|
|
||||||
|
|
||||||
//
|
|
||||||
// FIXME: Currently this is useless because the
|
|
||||||
// current implemetation doesn't list the 16-bit
|
|
||||||
// processes. I believe that would require querying
|
|
||||||
// each ntvdm.exe process for it's children.
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check or uncheck the show 16-bit tasks menu item
|
|
||||||
//
|
|
||||||
if (GetMenuState(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND) & MF_CHECKED)
|
|
||||||
{
|
|
||||||
CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_UNCHECKED);
|
|
||||||
TaskManagerSettings.Show16BitTasks = FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_CHECKED);
|
|
||||||
TaskManagerSettings.Show16BitTasks = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Refresh the list of processes.
|
|
||||||
//
|
|
||||||
RefreshProcessPage();
|
|
||||||
}
|
|
|
@ -1,878 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* perfdata.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include "stdafx.h"
|
|
||||||
#else
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "TaskMgr.h"
|
|
||||||
#include "perfdata.h"
|
|
||||||
|
|
||||||
PROCNTQSI NtQuerySystemInformation = NULL;
|
|
||||||
PROCGGR pGetGuiResources = NULL;
|
|
||||||
PROCGPIC pGetProcessIoCounters = NULL;
|
|
||||||
CRITICAL_SECTION PerfDataCriticalSection;
|
|
||||||
PPERFDATA pPerfDataOld = NULL; // Older perf data (saved to establish delta values)
|
|
||||||
PPERFDATA pPerfData = NULL; // Most recent copy of perf data
|
|
||||||
ULONG ProcessCountOld = 0;
|
|
||||||
ULONG ProcessCount = 0;
|
|
||||||
double dbIdleTime;
|
|
||||||
double dbKernelTime;
|
|
||||||
double dbSystemTime;
|
|
||||||
LARGE_INTEGER liOldIdleTime = {0,0};
|
|
||||||
double OldKernelTime = 0;
|
|
||||||
LARGE_INTEGER liOldSystemTime = {0,0};
|
|
||||||
SYSTEM_PERFORMANCE_INFORMATION SystemPerfInfo;
|
|
||||||
SYSTEM_BASIC_INFORMATION SystemBasicInfo;
|
|
||||||
SYSTEM_CACHE_INFORMATION SystemCacheInfo;
|
|
||||||
SYSTEM_HANDLE_INFORMATION SystemHandleInfo;
|
|
||||||
PSYSTEM_PROCESSORTIME_INFO SystemProcessorTimeInfo = NULL;
|
|
||||||
|
|
||||||
BOOL PerfDataInitialize(void)
|
|
||||||
{
|
|
||||||
LONG status;
|
|
||||||
|
|
||||||
NtQuerySystemInformation = (PROCNTQSI)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtQuerySystemInformation");
|
|
||||||
pGetGuiResources = (PROCGGR)GetProcAddress(GetModuleHandle("user32.dll"), "GetGuiResources");
|
|
||||||
pGetProcessIoCounters = (PROCGPIC)GetProcAddress(GetModuleHandle("kernel32.dll"), "GetProcessIoCounters");
|
|
||||||
|
|
||||||
InitializeCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (!NtQuerySystemInformation)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get number of processors in the system
|
|
||||||
//
|
|
||||||
status = NtQuerySystemInformation(SystemBasicInformation, &SystemBasicInfo, sizeof(SystemBasicInfo), NULL);
|
|
||||||
if (status != NO_ERROR)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PerfDataUninitialize(void)
|
|
||||||
{
|
|
||||||
NtQuerySystemInformation = NULL;
|
|
||||||
|
|
||||||
DeleteCriticalSection(&PerfDataCriticalSection);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PerfDataRefresh(void)
|
|
||||||
{
|
|
||||||
ULONG ulSize;
|
|
||||||
LONG status;
|
|
||||||
LPBYTE pBuffer;
|
|
||||||
ULONG BufferSize;
|
|
||||||
PSYSTEM_PROCESS_INFORMATION pSPI;
|
|
||||||
PPERFDATA pPDOld;
|
|
||||||
ULONG Idx, Idx2;
|
|
||||||
HANDLE hProcess;
|
|
||||||
HANDLE hProcessToken;
|
|
||||||
TCHAR szTemp[MAX_PATH];
|
|
||||||
DWORD dwSize;
|
|
||||||
SYSTEM_PERFORMANCE_INFORMATION SysPerfInfo;
|
|
||||||
SYSTEM_TIME_INFORMATION SysTimeInfo;
|
|
||||||
SYSTEM_CACHE_INFORMATION SysCacheInfo;
|
|
||||||
LPBYTE SysHandleInfoData;
|
|
||||||
PSYSTEM_PROCESSORTIME_INFO SysProcessorTimeInfo;
|
|
||||||
double CurrentKernelTime;
|
|
||||||
|
|
||||||
|
|
||||||
if (!NtQuerySystemInformation)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Get new system time
|
|
||||||
status = NtQuerySystemInformation(SystemTimeInformation, &SysTimeInfo, sizeof(SysTimeInfo), 0);
|
|
||||||
if (status != NO_ERROR)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Get new CPU's idle time
|
|
||||||
status = NtQuerySystemInformation(SystemPerformanceInformation, &SysPerfInfo, sizeof(SysPerfInfo), NULL);
|
|
||||||
if (status != NO_ERROR)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Get system cache information
|
|
||||||
status = NtQuerySystemInformation(SystemCacheInformation, &SysCacheInfo, sizeof(SysCacheInfo), NULL);
|
|
||||||
if (status != NO_ERROR)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Get processor time information
|
|
||||||
SysProcessorTimeInfo = new SYSTEM_PROCESSORTIME_INFO[SystemBasicInfo.bKeNumberProcessors];
|
|
||||||
status = NtQuerySystemInformation(SystemProcessorTimeInformation, SysProcessorTimeInfo, sizeof(SYSTEM_PROCESSORTIME_INFO) * SystemBasicInfo.bKeNumberProcessors, &ulSize);
|
|
||||||
if (status != NO_ERROR)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Get handle information
|
|
||||||
// We don't know how much data there is so just keep
|
|
||||||
// increasing the buffer size until the call succeeds
|
|
||||||
BufferSize = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
BufferSize += 0x10000;
|
|
||||||
SysHandleInfoData = new BYTE[BufferSize];
|
|
||||||
|
|
||||||
status = NtQuerySystemInformation(SystemHandleInformation, SysHandleInfoData, BufferSize, &ulSize);
|
|
||||||
|
|
||||||
if (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/)
|
|
||||||
delete[] SysHandleInfoData;
|
|
||||||
|
|
||||||
} while (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/);
|
|
||||||
|
|
||||||
// Get process information
|
|
||||||
// We don't know how much data there is so just keep
|
|
||||||
// increasing the buffer size until the call succeeds
|
|
||||||
BufferSize = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
BufferSize += 0x10000;
|
|
||||||
pBuffer = new BYTE[BufferSize];
|
|
||||||
|
|
||||||
status = NtQuerySystemInformation(SystemProcessInformation, pBuffer, BufferSize, &ulSize);
|
|
||||||
|
|
||||||
if (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/)
|
|
||||||
delete[] pBuffer;
|
|
||||||
|
|
||||||
} while (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/);
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Save system performance info
|
|
||||||
//
|
|
||||||
memcpy(&SystemPerfInfo, &SysPerfInfo, sizeof(SYSTEM_PERFORMANCE_INFORMATION));
|
|
||||||
|
|
||||||
//
|
|
||||||
// Save system cache info
|
|
||||||
//
|
|
||||||
memcpy(&SystemCacheInfo, &SysCacheInfo, sizeof(SYSTEM_CACHE_INFORMATION));
|
|
||||||
|
|
||||||
//
|
|
||||||
// Save system processor time info
|
|
||||||
//
|
|
||||||
if (SystemProcessorTimeInfo)
|
|
||||||
{
|
|
||||||
delete[] SystemProcessorTimeInfo;
|
|
||||||
}
|
|
||||||
SystemProcessorTimeInfo = SysProcessorTimeInfo;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Save system handle info
|
|
||||||
//
|
|
||||||
memcpy(&SystemHandleInfo, SysHandleInfoData, sizeof(SYSTEM_HANDLE_INFORMATION));
|
|
||||||
delete[] SysHandleInfoData;
|
|
||||||
|
|
||||||
for (CurrentKernelTime=0, Idx=0; Idx<SystemBasicInfo.bKeNumberProcessors; Idx++)
|
|
||||||
{
|
|
||||||
CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].KernelTime);
|
|
||||||
CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].DpcTime);
|
|
||||||
CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].InterruptTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If it's a first call - skip idle time calcs
|
|
||||||
if (liOldIdleTime.QuadPart != 0)
|
|
||||||
{
|
|
||||||
// CurrentValue = NewValue - OldValue
|
|
||||||
dbIdleTime = Li2Double(SysPerfInfo.liIdleTime) - Li2Double(liOldIdleTime);
|
|
||||||
dbKernelTime = CurrentKernelTime - OldKernelTime;
|
|
||||||
dbSystemTime = Li2Double(SysTimeInfo.liKeSystemTime) - Li2Double(liOldSystemTime);
|
|
||||||
|
|
||||||
// CurrentCpuIdle = IdleTime / SystemTime
|
|
||||||
dbIdleTime = dbIdleTime / dbSystemTime;
|
|
||||||
dbKernelTime = dbKernelTime / dbSystemTime;
|
|
||||||
|
|
||||||
// CurrentCpuUsage% = 100 - (CurrentCpuIdle * 100) / NumberOfProcessors
|
|
||||||
dbIdleTime = 100.0 - dbIdleTime * 100.0 / (double)SystemBasicInfo.bKeNumberProcessors;// + 0.5;
|
|
||||||
dbKernelTime = 100.0 - dbKernelTime * 100.0 / (double)SystemBasicInfo.bKeNumberProcessors;// + 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store new CPU's idle and system time
|
|
||||||
liOldIdleTime = SysPerfInfo.liIdleTime;
|
|
||||||
liOldSystemTime = SysTimeInfo.liKeSystemTime;
|
|
||||||
OldKernelTime = CurrentKernelTime;
|
|
||||||
|
|
||||||
// Determine the process count
|
|
||||||
// We loop through the data we got from NtQuerySystemInformation
|
|
||||||
// and count how many structures there are (until RelativeOffset is 0)
|
|
||||||
ProcessCountOld = ProcessCount;
|
|
||||||
ProcessCount = 0;
|
|
||||||
pSPI = (PSYSTEM_PROCESS_INFORMATION)pBuffer;
|
|
||||||
while (pSPI)
|
|
||||||
{
|
|
||||||
ProcessCount++;
|
|
||||||
|
|
||||||
if (pSPI->RelativeOffset == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->RelativeOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now alloc a new PERFDATA array and fill in the data
|
|
||||||
if (pPerfDataOld)
|
|
||||||
delete[] pPerfDataOld;
|
|
||||||
pPerfDataOld = pPerfData;
|
|
||||||
pPerfData = new PERFDATA[ProcessCount];
|
|
||||||
pSPI = (PSYSTEM_PROCESS_INFORMATION)pBuffer;
|
|
||||||
for (Idx=0; Idx<ProcessCount; Idx++)
|
|
||||||
{
|
|
||||||
// Get the old perf data for this process (if any)
|
|
||||||
// so that we can establish delta values
|
|
||||||
pPDOld = NULL;
|
|
||||||
for (Idx2=0; Idx2<ProcessCountOld; Idx2++)
|
|
||||||
{
|
|
||||||
if (pPerfDataOld[Idx2].ProcessId == pSPI->ProcessId)
|
|
||||||
{
|
|
||||||
pPDOld = &pPerfDataOld[Idx2];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear out process perf data structure
|
|
||||||
memset(&pPerfData[Idx], 0, sizeof(PERFDATA));
|
|
||||||
|
|
||||||
if (pSPI->Name.Buffer)
|
|
||||||
wcscpy(pPerfData[Idx].ImageName, pSPI->Name.Buffer);
|
|
||||||
else
|
|
||||||
wcscpy(pPerfData[Idx].ImageName, L"System Idle Process");
|
|
||||||
|
|
||||||
pPerfData[Idx].ProcessId = pSPI->ProcessId;
|
|
||||||
|
|
||||||
if (pPDOld)
|
|
||||||
{
|
|
||||||
double CurTime = Li2Double(pSPI->KernelTime) + Li2Double(pSPI->UserTime);
|
|
||||||
double OldTime = Li2Double(pPDOld->KernelTime) + Li2Double(pPDOld->UserTime);
|
|
||||||
|
|
||||||
double CpuTime = (CurTime - OldTime) / dbSystemTime;
|
|
||||||
|
|
||||||
CpuTime = CpuTime * 100.0 / (double)SystemBasicInfo.bKeNumberProcessors;// + 0.5;
|
|
||||||
|
|
||||||
pPerfData[Idx].CPUUsage = (ULONG)CpuTime;
|
|
||||||
}
|
|
||||||
pPerfData[Idx].CPUTime.QuadPart = pSPI->UserTime.QuadPart + pSPI->KernelTime.QuadPart;
|
|
||||||
pPerfData[Idx].WorkingSetSizeBytes = pSPI->TotalWorkingSetSizeBytes;
|
|
||||||
pPerfData[Idx].PeakWorkingSetSizeBytes = pSPI->PeakWorkingSetSizeBytes;
|
|
||||||
if (pPDOld)
|
|
||||||
pPerfData[Idx].WorkingSetSizeDelta = labs((LONG)pSPI->TotalWorkingSetSizeBytes - (LONG)pPDOld->WorkingSetSizeBytes);
|
|
||||||
else
|
|
||||||
pPerfData[Idx].WorkingSetSizeDelta = 0;
|
|
||||||
pPerfData[Idx].PageFaultCount = pSPI->PageFaultCount;
|
|
||||||
if (pPDOld)
|
|
||||||
pPerfData[Idx].PageFaultCountDelta = labs((LONG)pSPI->PageFaultCount - (LONG)pPDOld->PageFaultCount);
|
|
||||||
else
|
|
||||||
pPerfData[Idx].PageFaultCountDelta = 0;
|
|
||||||
pPerfData[Idx].VirtualMemorySizeBytes = pSPI->TotalVirtualSizeBytes;
|
|
||||||
pPerfData[Idx].PagedPoolUsagePages = pSPI->TotalPagedPoolUsagePages;
|
|
||||||
pPerfData[Idx].NonPagedPoolUsagePages = pSPI->TotalNonPagedPoolUsagePages;
|
|
||||||
pPerfData[Idx].BasePriority = pSPI->BasePriority;
|
|
||||||
pPerfData[Idx].HandleCount = pSPI->HandleCount;
|
|
||||||
pPerfData[Idx].ThreadCount = pSPI->ThreadCount;
|
|
||||||
|
|
||||||
pPerfData[Idx].SessionId = pSPI->SessionId;
|
|
||||||
|
|
||||||
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pSPI->ProcessId);
|
|
||||||
if (hProcess)
|
|
||||||
{
|
|
||||||
if (OpenProcessToken(hProcess, TOKEN_QUERY|TOKEN_DUPLICATE|TOKEN_IMPERSONATE, &hProcessToken))
|
|
||||||
{
|
|
||||||
ImpersonateLoggedOnUser(hProcessToken);
|
|
||||||
memset(szTemp, 0, sizeof(TCHAR[MAX_PATH]));
|
|
||||||
dwSize = MAX_PATH;
|
|
||||||
GetUserName(szTemp, &dwSize);
|
|
||||||
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szTemp, -1, pPerfData[Idx].UserName, MAX_PATH);
|
|
||||||
RevertToSelf();
|
|
||||||
|
|
||||||
CloseHandle(hProcessToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pGetGuiResources)
|
|
||||||
{
|
|
||||||
pPerfData[Idx].USERObjectCount = pGetGuiResources(hProcess, GR_USEROBJECTS);
|
|
||||||
pPerfData[Idx].GDIObjectCount = pGetGuiResources(hProcess, GR_GDIOBJECTS);
|
|
||||||
}
|
|
||||||
if (pGetProcessIoCounters)
|
|
||||||
pGetProcessIoCounters(hProcess, &pPerfData[Idx].IOCounters);
|
|
||||||
|
|
||||||
CloseHandle(hProcess);
|
|
||||||
}
|
|
||||||
|
|
||||||
pPerfData[Idx].UserTime.QuadPart = pSPI->UserTime.QuadPart;
|
|
||||||
pPerfData[Idx].KernelTime.QuadPart = pSPI->KernelTime.QuadPart;
|
|
||||||
|
|
||||||
pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->RelativeOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete[] pBuffer;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetProcessCount(void)
|
|
||||||
{
|
|
||||||
return ProcessCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetProcessorUsage(void)
|
|
||||||
{
|
|
||||||
return (ULONG)dbIdleTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetProcessorSystemUsage(void)
|
|
||||||
{
|
|
||||||
return (ULONG)dbKernelTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL PerfDataGetImageName(ULONG Index, LPTSTR lpImageName, int nMaxCount)
|
|
||||||
{
|
|
||||||
BOOL bSuccessful;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
{
|
|
||||||
#ifdef _UNICODE
|
|
||||||
wcsncpy(lpImageName, pPerfData[Index].ImageName, nMaxCount);
|
|
||||||
#else
|
|
||||||
WideCharToMultiByte(CP_ACP, 0, pPerfData[Index].ImageName, -1, lpImageName, nMaxCount, NULL, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bSuccessful = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
bSuccessful = FALSE;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return bSuccessful;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetProcessId(ULONG Index)
|
|
||||||
{
|
|
||||||
ULONG ProcessId;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
ProcessId = pPerfData[Index].ProcessId;
|
|
||||||
else
|
|
||||||
ProcessId = 0;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return ProcessId;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL PerfDataGetUserName(ULONG Index, LPTSTR lpUserName, int nMaxCount)
|
|
||||||
{
|
|
||||||
BOOL bSuccessful;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
{
|
|
||||||
#ifdef _UNICODE
|
|
||||||
wcsncpy(lpUserName, pPerfData[Index].UserName, nMaxCount);
|
|
||||||
#else
|
|
||||||
WideCharToMultiByte(CP_ACP, 0, pPerfData[Index].UserName, -1, lpUserName, nMaxCount, NULL, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bSuccessful = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
bSuccessful = FALSE;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return bSuccessful;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetSessionId(ULONG Index)
|
|
||||||
{
|
|
||||||
ULONG SessionId;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
SessionId = pPerfData[Index].SessionId;
|
|
||||||
else
|
|
||||||
SessionId = 0;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return SessionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetCPUUsage(ULONG Index)
|
|
||||||
{
|
|
||||||
ULONG CpuUsage;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
CpuUsage = pPerfData[Index].CPUUsage;
|
|
||||||
else
|
|
||||||
CpuUsage = 0;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return CpuUsage;
|
|
||||||
}
|
|
||||||
|
|
||||||
TIME PerfDataGetCPUTime(ULONG Index)
|
|
||||||
{
|
|
||||||
TIME CpuTime = {0,0};
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
CpuTime = pPerfData[Index].CPUTime;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return CpuTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetWorkingSetSizeBytes(ULONG Index)
|
|
||||||
{
|
|
||||||
ULONG WorkingSetSizeBytes;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
WorkingSetSizeBytes = pPerfData[Index].WorkingSetSizeBytes;
|
|
||||||
else
|
|
||||||
WorkingSetSizeBytes = 0;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return WorkingSetSizeBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetPeakWorkingSetSizeBytes(ULONG Index)
|
|
||||||
{
|
|
||||||
ULONG PeakWorkingSetSizeBytes;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
PeakWorkingSetSizeBytes = pPerfData[Index].PeakWorkingSetSizeBytes;
|
|
||||||
else
|
|
||||||
PeakWorkingSetSizeBytes = 0;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return PeakWorkingSetSizeBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetWorkingSetSizeDelta(ULONG Index)
|
|
||||||
{
|
|
||||||
ULONG WorkingSetSizeDelta;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
WorkingSetSizeDelta = pPerfData[Index].WorkingSetSizeDelta;
|
|
||||||
else
|
|
||||||
WorkingSetSizeDelta = 0;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return WorkingSetSizeDelta;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetPageFaultCount(ULONG Index)
|
|
||||||
{
|
|
||||||
ULONG PageFaultCount;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
PageFaultCount = pPerfData[Index].PageFaultCount;
|
|
||||||
else
|
|
||||||
PageFaultCount = 0;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return PageFaultCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetPageFaultCountDelta(ULONG Index)
|
|
||||||
{
|
|
||||||
ULONG PageFaultCountDelta;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
PageFaultCountDelta = pPerfData[Index].PageFaultCountDelta;
|
|
||||||
else
|
|
||||||
PageFaultCountDelta = 0;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return PageFaultCountDelta;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetVirtualMemorySizeBytes(ULONG Index)
|
|
||||||
{
|
|
||||||
ULONG VirtualMemorySizeBytes;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
VirtualMemorySizeBytes = pPerfData[Index].VirtualMemorySizeBytes;
|
|
||||||
else
|
|
||||||
VirtualMemorySizeBytes = 0;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return VirtualMemorySizeBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetPagedPoolUsagePages(ULONG Index)
|
|
||||||
{
|
|
||||||
ULONG PagedPoolUsagePages;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
PagedPoolUsagePages = pPerfData[Index].PagedPoolUsagePages;
|
|
||||||
else
|
|
||||||
PagedPoolUsagePages = 0;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return PagedPoolUsagePages;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetNonPagedPoolUsagePages(ULONG Index)
|
|
||||||
{
|
|
||||||
ULONG NonPagedPoolUsagePages;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
NonPagedPoolUsagePages = pPerfData[Index].NonPagedPoolUsagePages;
|
|
||||||
else
|
|
||||||
NonPagedPoolUsagePages = 0;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return NonPagedPoolUsagePages;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetBasePriority(ULONG Index)
|
|
||||||
{
|
|
||||||
ULONG BasePriority;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
BasePriority = pPerfData[Index].BasePriority;
|
|
||||||
else
|
|
||||||
BasePriority = 0;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return BasePriority;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetHandleCount(ULONG Index)
|
|
||||||
{
|
|
||||||
ULONG HandleCount;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
HandleCount = pPerfData[Index].HandleCount;
|
|
||||||
else
|
|
||||||
HandleCount = 0;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return HandleCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetThreadCount(ULONG Index)
|
|
||||||
{
|
|
||||||
ULONG ThreadCount;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
ThreadCount = pPerfData[Index].ThreadCount;
|
|
||||||
else
|
|
||||||
ThreadCount = 0;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return ThreadCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetUSERObjectCount(ULONG Index)
|
|
||||||
{
|
|
||||||
ULONG USERObjectCount;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
USERObjectCount = pPerfData[Index].USERObjectCount;
|
|
||||||
else
|
|
||||||
USERObjectCount = 0;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return USERObjectCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetGDIObjectCount(ULONG Index)
|
|
||||||
{
|
|
||||||
ULONG GDIObjectCount;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
GDIObjectCount = pPerfData[Index].GDIObjectCount;
|
|
||||||
else
|
|
||||||
GDIObjectCount = 0;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return GDIObjectCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL PerfDataGetIOCounters(ULONG Index, PIO_COUNTERS pIoCounters)
|
|
||||||
{
|
|
||||||
BOOL bSuccessful;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
if (Index < ProcessCount)
|
|
||||||
{
|
|
||||||
memcpy(pIoCounters, &pPerfData[Index].IOCounters, sizeof(IO_COUNTERS));
|
|
||||||
bSuccessful = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
bSuccessful = FALSE;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return bSuccessful;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetCommitChargeTotalK(void)
|
|
||||||
{
|
|
||||||
ULONG Total;
|
|
||||||
ULONG PageSize;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
Total = SystemPerfInfo.MmTotalCommitedPages;
|
|
||||||
PageSize = SystemBasicInfo.uPageSize;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
Total = Total * (PageSize / 1024);
|
|
||||||
|
|
||||||
return Total;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetCommitChargeLimitK(void)
|
|
||||||
{
|
|
||||||
ULONG Limit;
|
|
||||||
ULONG PageSize;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
Limit = SystemPerfInfo.MmTotalCommitLimit;
|
|
||||||
PageSize = SystemBasicInfo.uPageSize;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
Limit = Limit * (PageSize / 1024);
|
|
||||||
|
|
||||||
return Limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetCommitChargePeakK(void)
|
|
||||||
{
|
|
||||||
ULONG Peak;
|
|
||||||
ULONG PageSize;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
Peak = SystemPerfInfo.MmPeakLimit;
|
|
||||||
PageSize = SystemBasicInfo.uPageSize;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
Peak = Peak * (PageSize / 1024);
|
|
||||||
|
|
||||||
return Peak;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetKernelMemoryTotalK(void)
|
|
||||||
{
|
|
||||||
ULONG Total;
|
|
||||||
ULONG Paged;
|
|
||||||
ULONG NonPaged;
|
|
||||||
ULONG PageSize;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
Paged = SystemPerfInfo.PoolPagedBytes;
|
|
||||||
NonPaged = SystemPerfInfo.PoolNonPagedBytes;
|
|
||||||
PageSize = SystemBasicInfo.uPageSize;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
Paged = Paged * (PageSize / 1024);
|
|
||||||
NonPaged = NonPaged * (PageSize / 1024);
|
|
||||||
|
|
||||||
Total = Paged + NonPaged;
|
|
||||||
|
|
||||||
return Total;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetKernelMemoryPagedK(void)
|
|
||||||
{
|
|
||||||
ULONG Paged;
|
|
||||||
ULONG PageSize;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
Paged = SystemPerfInfo.PoolPagedBytes;
|
|
||||||
PageSize = SystemBasicInfo.uPageSize;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
Paged = Paged * (PageSize / 1024);
|
|
||||||
|
|
||||||
return Paged;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetKernelMemoryNonPagedK(void)
|
|
||||||
{
|
|
||||||
ULONG NonPaged;
|
|
||||||
ULONG PageSize;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
NonPaged = SystemPerfInfo.PoolNonPagedBytes;
|
|
||||||
PageSize = SystemBasicInfo.uPageSize;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
NonPaged = NonPaged * (PageSize / 1024);
|
|
||||||
|
|
||||||
return NonPaged;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetPhysicalMemoryTotalK(void)
|
|
||||||
{
|
|
||||||
ULONG Total;
|
|
||||||
ULONG PageSize;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
Total = SystemBasicInfo.uMmNumberOfPhysicalPages;
|
|
||||||
PageSize = SystemBasicInfo.uPageSize;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
Total = Total * (PageSize / 1024);
|
|
||||||
|
|
||||||
return Total;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetPhysicalMemoryAvailableK(void)
|
|
||||||
{
|
|
||||||
ULONG Available;
|
|
||||||
ULONG PageSize;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
Available = SystemPerfInfo.MmAvailablePages;
|
|
||||||
PageSize = SystemBasicInfo.uPageSize;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
Available = Available * (PageSize / 1024);
|
|
||||||
|
|
||||||
return Available;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetPhysicalMemorySystemCacheK(void)
|
|
||||||
{
|
|
||||||
ULONG SystemCache;
|
|
||||||
ULONG PageSize;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
SystemCache = SystemCacheInfo.CurrentSize;
|
|
||||||
PageSize = SystemBasicInfo.uPageSize;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
//SystemCache = SystemCache * (PageSize / 1024);
|
|
||||||
SystemCache = SystemCache / 1024;
|
|
||||||
|
|
||||||
return SystemCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetSystemHandleCount(void)
|
|
||||||
{
|
|
||||||
ULONG HandleCount;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
HandleCount = SystemHandleInfo.Count;
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return HandleCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG PerfDataGetTotalThreadCount(void)
|
|
||||||
{
|
|
||||||
ULONG ThreadCount = 0;
|
|
||||||
ULONG i;
|
|
||||||
|
|
||||||
EnterCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
for (i=0; i<ProcessCount; i++)
|
|
||||||
{
|
|
||||||
ThreadCount += pPerfData[i].ThreadCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
|
||||||
|
|
||||||
return ThreadCount;
|
|
||||||
}
|
|
|
@ -1,328 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* priority.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include "stdafx.h"
|
|
||||||
#else
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "taskmgr.h"
|
|
||||||
#include "priority.h"
|
|
||||||
#include "ProcessPage.h"
|
|
||||||
#include "perfdata.h"
|
|
||||||
|
|
||||||
void ProcessPage_OnSetPriorityRealTime(void)
|
|
||||||
{
|
|
||||||
LVITEM lvitem;
|
|
||||||
ULONG Index;
|
|
||||||
DWORD dwProcessId;
|
|
||||||
HANDLE hProcess;
|
|
||||||
TCHAR strErrorText[260];
|
|
||||||
|
|
||||||
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
|
|
||||||
{
|
|
||||||
memset(&lvitem, 0, sizeof(LVITEM));
|
|
||||||
|
|
||||||
lvitem.mask = LVIF_STATE;
|
|
||||||
lvitem.stateMask = LVIS_SELECTED;
|
|
||||||
lvitem.iItem = Index;
|
|
||||||
|
|
||||||
ListView_GetItem(hProcessPageListCtrl, &lvitem);
|
|
||||||
|
|
||||||
if (lvitem.state & LVIS_SELECTED)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwProcessId = PerfDataGetProcessId(Index);
|
|
||||||
|
|
||||||
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (MessageBox(hMainWnd, "WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?", "Task Manager Warning", MB_YESNO|MB_ICONWARNING) != IDYES)
|
|
||||||
return;
|
|
||||||
|
|
||||||
hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId);
|
|
||||||
|
|
||||||
if (!hProcess)
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Change Priority", MB_OK|MB_ICONSTOP);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SetPriorityClass(hProcess, REALTIME_PRIORITY_CLASS))
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Change Priority", MB_OK|MB_ICONSTOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(hProcess);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessPage_OnSetPriorityHigh(void)
|
|
||||||
{
|
|
||||||
LVITEM lvitem;
|
|
||||||
ULONG Index;
|
|
||||||
DWORD dwProcessId;
|
|
||||||
HANDLE hProcess;
|
|
||||||
TCHAR strErrorText[260];
|
|
||||||
|
|
||||||
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
|
|
||||||
{
|
|
||||||
memset(&lvitem, 0, sizeof(LVITEM));
|
|
||||||
|
|
||||||
lvitem.mask = LVIF_STATE;
|
|
||||||
lvitem.stateMask = LVIS_SELECTED;
|
|
||||||
lvitem.iItem = Index;
|
|
||||||
|
|
||||||
ListView_GetItem(hProcessPageListCtrl, &lvitem);
|
|
||||||
|
|
||||||
if (lvitem.state & LVIS_SELECTED)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwProcessId = PerfDataGetProcessId(Index);
|
|
||||||
|
|
||||||
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (MessageBox(hMainWnd, "WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?", "Task Manager Warning", MB_YESNO|MB_ICONWARNING) != IDYES)
|
|
||||||
return;
|
|
||||||
|
|
||||||
hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId);
|
|
||||||
|
|
||||||
if (!hProcess)
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Change Priority", MB_OK|MB_ICONSTOP);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS))
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Change Priority", MB_OK|MB_ICONSTOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(hProcess);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessPage_OnSetPriorityAboveNormal(void)
|
|
||||||
{
|
|
||||||
LVITEM lvitem;
|
|
||||||
ULONG Index;
|
|
||||||
DWORD dwProcessId;
|
|
||||||
HANDLE hProcess;
|
|
||||||
TCHAR strErrorText[260];
|
|
||||||
|
|
||||||
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
|
|
||||||
{
|
|
||||||
memset(&lvitem, 0, sizeof(LVITEM));
|
|
||||||
|
|
||||||
lvitem.mask = LVIF_STATE;
|
|
||||||
lvitem.stateMask = LVIS_SELECTED;
|
|
||||||
lvitem.iItem = Index;
|
|
||||||
|
|
||||||
ListView_GetItem(hProcessPageListCtrl, &lvitem);
|
|
||||||
|
|
||||||
if (lvitem.state & LVIS_SELECTED)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwProcessId = PerfDataGetProcessId(Index);
|
|
||||||
|
|
||||||
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (MessageBox(hMainWnd, "WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?", "Task Manager Warning", MB_YESNO|MB_ICONWARNING) != IDYES)
|
|
||||||
return;
|
|
||||||
|
|
||||||
hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId);
|
|
||||||
|
|
||||||
if (!hProcess)
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Change Priority", MB_OK|MB_ICONSTOP);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SetPriorityClass(hProcess, ABOVE_NORMAL_PRIORITY_CLASS))
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Change Priority", MB_OK|MB_ICONSTOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(hProcess);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessPage_OnSetPriorityNormal(void)
|
|
||||||
{
|
|
||||||
LVITEM lvitem;
|
|
||||||
ULONG Index;
|
|
||||||
DWORD dwProcessId;
|
|
||||||
HANDLE hProcess;
|
|
||||||
TCHAR strErrorText[260];
|
|
||||||
|
|
||||||
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
|
|
||||||
{
|
|
||||||
memset(&lvitem, 0, sizeof(LVITEM));
|
|
||||||
|
|
||||||
lvitem.mask = LVIF_STATE;
|
|
||||||
lvitem.stateMask = LVIS_SELECTED;
|
|
||||||
lvitem.iItem = Index;
|
|
||||||
|
|
||||||
ListView_GetItem(hProcessPageListCtrl, &lvitem);
|
|
||||||
|
|
||||||
if (lvitem.state & LVIS_SELECTED)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwProcessId = PerfDataGetProcessId(Index);
|
|
||||||
|
|
||||||
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (MessageBox(hMainWnd, "WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?", "Task Manager Warning", MB_YESNO|MB_ICONWARNING) != IDYES)
|
|
||||||
return;
|
|
||||||
|
|
||||||
hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId);
|
|
||||||
|
|
||||||
if (!hProcess)
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Change Priority", MB_OK|MB_ICONSTOP);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SetPriorityClass(hProcess, NORMAL_PRIORITY_CLASS))
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Change Priority", MB_OK|MB_ICONSTOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(hProcess);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessPage_OnSetPriorityBelowNormal(void)
|
|
||||||
{
|
|
||||||
LVITEM lvitem;
|
|
||||||
ULONG Index;
|
|
||||||
DWORD dwProcessId;
|
|
||||||
HANDLE hProcess;
|
|
||||||
TCHAR strErrorText[260];
|
|
||||||
|
|
||||||
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
|
|
||||||
{
|
|
||||||
memset(&lvitem, 0, sizeof(LVITEM));
|
|
||||||
|
|
||||||
lvitem.mask = LVIF_STATE;
|
|
||||||
lvitem.stateMask = LVIS_SELECTED;
|
|
||||||
lvitem.iItem = Index;
|
|
||||||
|
|
||||||
ListView_GetItem(hProcessPageListCtrl, &lvitem);
|
|
||||||
|
|
||||||
if (lvitem.state & LVIS_SELECTED)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwProcessId = PerfDataGetProcessId(Index);
|
|
||||||
|
|
||||||
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (MessageBox(hMainWnd, "WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?", "Task Manager Warning", MB_YESNO|MB_ICONWARNING) != IDYES)
|
|
||||||
return;
|
|
||||||
|
|
||||||
hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId);
|
|
||||||
|
|
||||||
if (!hProcess)
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Change Priority", MB_OK|MB_ICONSTOP);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SetPriorityClass(hProcess, BELOW_NORMAL_PRIORITY_CLASS))
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Change Priority", MB_OK|MB_ICONSTOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(hProcess);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessPage_OnSetPriorityLow(void)
|
|
||||||
{
|
|
||||||
LVITEM lvitem;
|
|
||||||
ULONG Index;
|
|
||||||
DWORD dwProcessId;
|
|
||||||
HANDLE hProcess;
|
|
||||||
TCHAR strErrorText[260];
|
|
||||||
|
|
||||||
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
|
|
||||||
{
|
|
||||||
memset(&lvitem, 0, sizeof(LVITEM));
|
|
||||||
|
|
||||||
lvitem.mask = LVIF_STATE;
|
|
||||||
lvitem.stateMask = LVIS_SELECTED;
|
|
||||||
lvitem.iItem = Index;
|
|
||||||
|
|
||||||
ListView_GetItem(hProcessPageListCtrl, &lvitem);
|
|
||||||
|
|
||||||
if (lvitem.state & LVIS_SELECTED)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwProcessId = PerfDataGetProcessId(Index);
|
|
||||||
|
|
||||||
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (MessageBox(hMainWnd, "WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?", "Task Manager Warning", MB_YESNO|MB_ICONWARNING) != IDYES)
|
|
||||||
return;
|
|
||||||
|
|
||||||
hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId);
|
|
||||||
|
|
||||||
if (!hProcess)
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Change Priority", MB_OK|MB_ICONSTOP);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SetPriorityClass(hProcess, IDLE_PRIORITY_CLASS))
|
|
||||||
{
|
|
||||||
GetLastErrorText(strErrorText, 260);
|
|
||||||
MessageBox(hMainWnd, strErrorText, "Unable to Change Priority", MB_OK|MB_ICONSTOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(hProcess);
|
|
||||||
}
|
|
|
@ -1,126 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* proclist.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include "stdafx.h"
|
|
||||||
#else
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "taskmgr.h"
|
|
||||||
#include "ProcessPage.h"
|
|
||||||
#include "proclist.h"
|
|
||||||
#include "perfdata.h"
|
|
||||||
|
|
||||||
|
|
||||||
LRESULT CALLBACK ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
|
||||||
|
|
||||||
LONG OldProcessListWndProc;
|
|
||||||
|
|
||||||
|
|
||||||
LRESULT CALLBACK ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
HBRUSH hbrBackground;
|
|
||||||
RECT rcItem;
|
|
||||||
RECT rcClip;
|
|
||||||
HDC hDC;
|
|
||||||
int DcSave;
|
|
||||||
|
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
case WM_ERASEBKGND:
|
|
||||||
|
|
||||||
//
|
|
||||||
// The list control produces a nasty flicker
|
|
||||||
// when the user is resizing the window because
|
|
||||||
// it erases the background to white, then
|
|
||||||
// paints the list items over it.
|
|
||||||
//
|
|
||||||
// We will clip the drawing so that it only
|
|
||||||
// erases the parts of the list control that
|
|
||||||
// show only the background.
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get the device context and save it's state
|
|
||||||
// to be restored after we're done
|
|
||||||
//
|
|
||||||
hDC = (HDC) wParam;
|
|
||||||
DcSave = SaveDC(hDC);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get the background brush
|
|
||||||
//
|
|
||||||
hbrBackground = (HBRUSH) GetClassLong(hWnd, GCL_HBRBACKGROUND);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Calculate the clip rect by getting the RECT
|
|
||||||
// of the first and last items and adding them up.
|
|
||||||
//
|
|
||||||
// We also have to get the item's icon RECT and
|
|
||||||
// subtract it from our clip rect because we don't
|
|
||||||
// use icons in this list control.
|
|
||||||
//
|
|
||||||
ListView_GetItemRect(hWnd, 0, &rcClip, LVIR_BOUNDS);
|
|
||||||
ListView_GetItemRect(hWnd, ListView_GetItemCount(hWnd) - 1, &rcItem, LVIR_BOUNDS);
|
|
||||||
rcClip.bottom = rcItem.bottom;
|
|
||||||
ListView_GetItemRect(hWnd, 0, &rcItem, LVIR_ICON);
|
|
||||||
rcClip.left = rcItem.right;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Now exclude the clip rect
|
|
||||||
//
|
|
||||||
ExcludeClipRect(hDC, rcClip.left, rcClip.top, rcClip.right, rcClip.bottom);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Now erase the background
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// FIXME: Should I erase it myself or
|
|
||||||
// pass down the updated HDC and let
|
|
||||||
// the default handler do it?
|
|
||||||
//
|
|
||||||
GetClientRect(hWnd, &rcItem);
|
|
||||||
FillRect(hDC, &rcItem, hbrBackground);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Now restore the DC state that we
|
|
||||||
// saved earlier
|
|
||||||
//
|
|
||||||
RestoreDC(hDC, DcSave);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// We pass on all messages except WM_ERASEBKGND
|
|
||||||
//
|
|
||||||
return CallWindowProc((WNDPROC)OldProcessListWndProc, hWnd, message, wParam, lParam);
|
|
||||||
}
|
|
|
@ -1,70 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* run.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include "stdafx.h"
|
|
||||||
#else
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "taskmgr.h"
|
|
||||||
#include "run.h"
|
|
||||||
|
|
||||||
void TaskManager_OnFileNew(void)
|
|
||||||
{
|
|
||||||
HMODULE hShell32;
|
|
||||||
RUNFILEDLG RunFileDlg;
|
|
||||||
OSVERSIONINFO versionInfo;
|
|
||||||
WCHAR wTitle[40];
|
|
||||||
WCHAR wText[256];
|
|
||||||
char szTitle[40] = "Create New Task";
|
|
||||||
char szText[256] = "Type the name of a program, folder, document, or Internet resource, and Task Manager will open it for you.";
|
|
||||||
|
|
||||||
hShell32 = LoadLibrary("SHELL32.DLL");
|
|
||||||
RunFileDlg = (RUNFILEDLG)(FARPROC)GetProcAddress(hShell32, (char*)((long)0x3D));
|
|
||||||
|
|
||||||
// Show "Run..." dialog
|
|
||||||
if (RunFileDlg)
|
|
||||||
{
|
|
||||||
versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
|
||||||
GetVersionEx(&versionInfo);
|
|
||||||
|
|
||||||
if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
|
||||||
{
|
|
||||||
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szTitle, -1, wTitle, 40);
|
|
||||||
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szText, -1, wText, 256);
|
|
||||||
RunFileDlg(hMainWnd, 0, NULL, (LPCSTR)wTitle, (LPCSTR)wText, RFF_CALCDIRECTORY);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
RunFileDlg(hMainWnd, 0, NULL, szTitle, szText, RFF_CALCDIRECTORY);
|
|
||||||
}
|
|
||||||
|
|
||||||
FreeLibrary(hShell32);
|
|
||||||
}
|
|
|
@ -1,217 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS Task Manager
|
|
||||||
*
|
|
||||||
* trayicon.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include "stdafx.h"
|
|
||||||
#else
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "taskmgr.h"
|
|
||||||
#include "trayicon.h"
|
|
||||||
#include "perfdata.h"
|
|
||||||
#include "shellapi.h"
|
|
||||||
|
|
||||||
HICON TrayIcon_GetProcessorUsageIcon(void)
|
|
||||||
{
|
|
||||||
HICON hTrayIcon = NULL;
|
|
||||||
HDC hScreenDC = NULL;
|
|
||||||
HDC hDC = NULL;
|
|
||||||
HBITMAP hBitmap = NULL;
|
|
||||||
HBITMAP hOldBitmap = NULL;
|
|
||||||
HBITMAP hBitmapMask = NULL;
|
|
||||||
ICONINFO iconInfo;
|
|
||||||
ULONG ProcessorUsage;
|
|
||||||
int nLinesToDraw;
|
|
||||||
HBRUSH hBitmapBrush = NULL;
|
|
||||||
RECT rc;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get a handle to the screen DC
|
|
||||||
//
|
|
||||||
hScreenDC = GetDC(NULL);
|
|
||||||
if (!hScreenDC)
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Create our own DC from it
|
|
||||||
//
|
|
||||||
hDC = CreateCompatibleDC(hScreenDC);
|
|
||||||
if (!hDC)
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Load the bitmaps
|
|
||||||
//
|
|
||||||
hBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_TRAYICON));
|
|
||||||
hBitmapMask = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_TRAYMASK));
|
|
||||||
if (!hBitmap || !hBitmapMask)
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
hBitmapBrush = CreateSolidBrush(RGB(0, 255, 0));
|
|
||||||
if (!hBitmapBrush)
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Select the bitmap into our device context
|
|
||||||
// so we can draw on it.
|
|
||||||
//
|
|
||||||
hOldBitmap = (HBITMAP) SelectObject(hDC, hBitmap);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get the cpu usage
|
|
||||||
//
|
|
||||||
ProcessorUsage = PerfDataGetProcessorUsage();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Calculate how many lines to draw
|
|
||||||
// since we have 11 rows of space
|
|
||||||
// to draw the cpu usage instead of
|
|
||||||
// just having 10.
|
|
||||||
//
|
|
||||||
nLinesToDraw = (ProcessorUsage + (ProcessorUsage / 10)) / 11;
|
|
||||||
rc.left = 3;
|
|
||||||
rc.top = 12 - nLinesToDraw;
|
|
||||||
rc.right = 13;
|
|
||||||
rc.bottom = 13;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Now draw the cpu usage
|
|
||||||
//
|
|
||||||
if (nLinesToDraw)
|
|
||||||
FillRect(hDC, &rc, hBitmapBrush);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Now that we are done drawing put the
|
|
||||||
// old bitmap back.
|
|
||||||
//
|
|
||||||
SelectObject(hDC, hOldBitmap);
|
|
||||||
hOldBitmap = NULL;
|
|
||||||
|
|
||||||
iconInfo.fIcon = TRUE;
|
|
||||||
iconInfo.xHotspot = 0;
|
|
||||||
iconInfo.yHotspot = 0;
|
|
||||||
iconInfo.hbmMask = hBitmapMask;
|
|
||||||
iconInfo.hbmColor = hBitmap;
|
|
||||||
|
|
||||||
hTrayIcon = CreateIconIndirect(&iconInfo);
|
|
||||||
|
|
||||||
done:
|
|
||||||
//
|
|
||||||
// Cleanup
|
|
||||||
//
|
|
||||||
if (hScreenDC)
|
|
||||||
ReleaseDC(NULL, hScreenDC);
|
|
||||||
if (hOldBitmap)
|
|
||||||
SelectObject(hDC, hOldBitmap);
|
|
||||||
if (hDC)
|
|
||||||
DeleteDC(hDC);
|
|
||||||
if (hBitmapBrush)
|
|
||||||
DeleteObject(hBitmapBrush);
|
|
||||||
if (hBitmap)
|
|
||||||
DeleteObject(hBitmap);
|
|
||||||
if (hBitmapMask)
|
|
||||||
DeleteObject(hBitmapMask);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Return the newly created tray icon (if successful)
|
|
||||||
//
|
|
||||||
return hTrayIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL TrayIcon_ShellAddTrayIcon(void)
|
|
||||||
{
|
|
||||||
NOTIFYICONDATA nid;
|
|
||||||
HICON hIcon = NULL;
|
|
||||||
BOOL bRetVal;
|
|
||||||
|
|
||||||
memset(&nid, 0, sizeof(NOTIFYICONDATA));
|
|
||||||
|
|
||||||
hIcon = TrayIcon_GetProcessorUsageIcon();
|
|
||||||
|
|
||||||
nid.cbSize = sizeof(NOTIFYICONDATA);
|
|
||||||
nid.hWnd = hMainWnd;
|
|
||||||
nid.uID = 0;
|
|
||||||
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
|
||||||
//nid.uCallbackMessage = ??;
|
|
||||||
nid.hIcon = hIcon;
|
|
||||||
sprintf(nid.szTip, "CPU Usage: %d%%", PerfDataGetProcessorUsage());
|
|
||||||
|
|
||||||
bRetVal = Shell_NotifyIcon(NIM_ADD, &nid);
|
|
||||||
|
|
||||||
if (hIcon)
|
|
||||||
DeleteObject(hIcon);
|
|
||||||
|
|
||||||
return bRetVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL TrayIcon_ShellRemoveTrayIcon(void)
|
|
||||||
{
|
|
||||||
NOTIFYICONDATA nid;
|
|
||||||
BOOL bRetVal;
|
|
||||||
|
|
||||||
memset(&nid, 0, sizeof(NOTIFYICONDATA));
|
|
||||||
|
|
||||||
nid.cbSize = sizeof(NOTIFYICONDATA);
|
|
||||||
nid.hWnd = hMainWnd;
|
|
||||||
nid.uID = 0;
|
|
||||||
nid.uFlags = 0;
|
|
||||||
//nid.uCallbackMessage = ??;
|
|
||||||
|
|
||||||
bRetVal = Shell_NotifyIcon(NIM_DELETE, &nid);
|
|
||||||
|
|
||||||
return bRetVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL TrayIcon_ShellUpdateTrayIcon(void)
|
|
||||||
{
|
|
||||||
NOTIFYICONDATA nid;
|
|
||||||
HICON hIcon = NULL;
|
|
||||||
BOOL bRetVal;
|
|
||||||
|
|
||||||
memset(&nid, 0, sizeof(NOTIFYICONDATA));
|
|
||||||
|
|
||||||
hIcon = TrayIcon_GetProcessorUsageIcon();
|
|
||||||
|
|
||||||
nid.cbSize = sizeof(NOTIFYICONDATA);
|
|
||||||
nid.hWnd = hMainWnd;
|
|
||||||
nid.uID = 0;
|
|
||||||
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
|
||||||
//nid.uCallbackMessage = ??;
|
|
||||||
nid.hIcon = hIcon;
|
|
||||||
sprintf(nid.szTip, "CPU Usage: %d%%", PerfDataGetProcessorUsage());
|
|
||||||
|
|
||||||
bRetVal = Shell_NotifyIcon(NIM_MODIFY, &nid);
|
|
||||||
|
|
||||||
if (hIcon)
|
|
||||||
DeleteObject(hIcon);
|
|
||||||
|
|
||||||
return bRetVal;
|
|
||||||
}
|
|
Loading…
Reference in a new issue