Click here to Skip to main content
15,895,746 members
Articles / Desktop Programming / MFC

Task Manager Extension 2.0

Rate me:
Please Sign up or sign in to vote.
4.92/5 (149 votes)
22 Jan 2007CDDL11 min read 598.4K   18.7K   263  
Task Manager Extension. This is a Windows Task Manager (NT/2000/XP/2003) plug-in. It adds lots of useful features to the standard Task Manager. It can show process modules, memory map, used handles, open files, file properties and a lot of other info!
// CAboutExtension.cpp : implementation file
//

#include "stdafx.h"
//#include "taskmanagerexdll.h"
#include "AboutExtension.h"
#include "DllVersion.h"
#include "Localization.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

IMPLEMENT_DYNCREATE( CAboutExtensionThread, CWinThread )

BOOL CAboutExtensionThread::InitInstance()
{
	SetThreadNativeLanguage();
	CAboutExtension dlg( AfxGetMainWnd() );
	m_pMainWnd = &dlg;

	dlg.DoModal();

	PostQuitMessage( 0 ); // quit thread gracefully
	return TRUE;
//	return FALSE; // return error to quit thread
}

CAboutExtensionThread* CAboutExtensionThread::Start()
{
//	return (CAboutExtensionThread*)::AfxBeginThread( RUNTIME_CLASS(CAboutExtensionThread) );

	// Always modal dialog:

	SetThreadNativeLanguage();
	CAboutExtension dlg( AfxGetMainWnd() );
	dlg.DoModal();

	return FALSE;
}

/////////////////////////////////////////////////////////////////////////////
// CAboutExtension dialog

CAboutExtension::CAboutExtension(CWnd* pParent /*=NULL*/)
	: CDialog(CAboutExtension::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAboutExtension)
	m_strVersion = _T("");
	m_strComments = _T("");
	//}}AFX_DATA_INIT

	TCHAR szTaskManagerExDll[MAX_PATH] = _T("");
	GetModuleFileName( AfxGetInstanceHandle(), szTaskManagerExDll, SIZEOF_ARRAY(szTaskManagerExDll) );
	CString version;

	GetModuleProductVersion( szTaskManagerExDll, version );

	/*
	// Usually version has the form "1, 2, 0, 0"...
	version.Replace( _T(','), _T('.') );
	version.Remove( _T(' ') );
	int pos;
	pos = version.Find( _T('.') );
	if( pos != -1 )
	{
		pos = version.Find( _T('.'), pos + 1 );
		if( pos != -1 )
		{
			version = version.Left(pos);
		}
	}
	*/

	m_strVersion.Format( _T("Task Manager Extension %s"), version );
	GetModuleComment( szTaskManagerExDll, m_strComments );
}


void CAboutExtension::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutExtension)
	DDX_Text(pDX, IDC_PRODUCT_VERSION_STATIC, m_strVersion);
	DDX_Text(pDX, IDC_COMMENTS_STATIC, m_strComments);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAboutExtension, CDialog)
	//{{AFX_MSG_MAP(CAboutExtension)
	ON_WM_HELPINFO()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAboutExtension message handlers


BOOL CAboutExtension::PreTranslateMessage(MSG* pMsg) 
{
	// CG: The following block was added by the ToolTips component.
	{
		// Let the ToolTip process this message.
		m_tooltip.RelayEvent(pMsg);
	}

	return CDialog::PreTranslateMessage(pMsg);
}

BOOL CAboutExtension::OnHelpInfo(HELPINFO* pHelpInfo) 
{

	return CDialog::OnHelpInfo(pHelpInfo);
}

/////////////////////////////////////////////////////////////////////////////

BOOL CAboutExtension::OnInitDialog() 
{
	CDialog::OnInitDialog();

	// TODO: Add extra initialization here

	// CG: The following block was added by the ToolTips component.
	{
		// Create the ToolTip control.
		m_tooltip.Create(this);
		m_tooltip.Activate(TRUE);

		// TODO: Use one of the following forms to add controls:
		// m_tooltip.AddTool(GetDlgItem(IDC_<name>), <string-table-id>);
		// m_tooltip.AddTool(GetDlgItem(IDC_<name>), "<text>");
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

/////////////////////////////////////////////////////////////////////////////

int CAboutExtension::DoModal() 
{
	// load resource as necessary
	if( m_lpszTemplateName != NULL && m_lpDialogTemplate == NULL )
	{
		m_lpDialogTemplate = LocLoadDialog( m_lpszTemplateName );
		m_lpszTemplateName = NULL;
	}

	return CDialog::DoModal();
}

/////////////////////////////////////////////////////////////////////////////

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, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)


Written By
Software Developer (Senior)
Belarus Belarus
He is a young and forward-looking software developer. He also has lots of interesting hobbies like snowboarding, bicycle riding, carting racing and of course talking about himself in a third person. Smile | :)

github.com/kolomenkin

Curriculum Vitae

Comments and Discussions