Click here to Skip to main content
15,886,724 members
Articles / Programming Languages / C++

Enum Processes with kernel and user times

Rate me:
Please Sign up or sign in to vote.
4.25/5 (11 votes)
7 Feb 20052 min read 91.7K   1.4K   23  
An article on enumerating processes.
// console.cpp
//
#include "stdafx.h"
#include "console.h"

using namespace std;

//
// Clears the screen
//
void clrscr(int screenSize)
{
	if(screenSize == MAXIMUM)
	{
		CONSOLE_SCREEN_BUFFER_INFO csbi; 
		HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 
		GetConsoleScreenBufferInfo(hConsole, &csbi); 
		COORD coord = GetLargestConsoleWindowSize(hConsole);
		SMALL_RECT rc;
		rc.Left = csbi.srWindow.Left;
		rc.Top = csbi.srWindow.Top;
		rc.Right = csbi.srWindow.Right;
		rc.Bottom = coord.Y - 1;	// Must be 1 less
		SetConsoleWindowInfo(hConsole, TRUE, &rc);
	}
	COORD coordScreen = { 0, 0 }; 
	DWORD cCharsWritten; 
	CONSOLE_SCREEN_BUFFER_INFO csbi; 
	DWORD dwConSize; 
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 
  
	GetConsoleScreenBufferInfo(hConsole, &csbi); 
	dwConSize = csbi.dwSize.X * csbi.dwSize.Y; 
	FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten); 
	GetConsoleScreenBufferInfo(hConsole, &csbi); 
	FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten); 
	SetConsoleCursorPosition(hConsole, coordScreen); 
}

//
// Moves the cursor to x, y in console window
// ie x=left\right y=top\bottom
//
void gotoxy(int x, int y)
{
	COORD point;
	point.X = x; point.Y = y;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), point);
}

//
// Set text and background colors
//
void setrgb(int bgc, int fgc)
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),((bgc<<4)+fgc));
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions