Click here to Skip to main content
11,489,574 members (65,612 online)
Click here to Skip to main content
Add your own
alternative version

Task Manager for Windows Mobile and Windows CE

, 30 Nov 2008 CPOL 66.7K 4.9K 73
Source code for writing your own Task Manager for Windows Mobile or Windows CE based devices
CETaskManager_demo.zip
Documents and Settings
Werner
My Documents
The CodeProject
CETaskManager_V2
CETaskManager.CAB
CETaskManager_src.zip
CETaskManager
CAB
TaskManager.vddproj
CEChart
bin
Release
CE
CEchart.dll
CEchart.pdb
CETaskManager
Properties
Settings.settings
Res
TaskMgr.ico
TaskMgr.ico
ToolBox
Idl
Res
CpuLoad.rgs
CpuLoadDCOM.rgs
Process.rgs
ProcessDCOM.rgs
ProcessList.rgs
ProcessListDCOM.rgs
System.rgs
SystemDCOM.rgs
ToolBox.def
ToolBox.rgs
ToolBoxdcom.rgs
Src
Threads
Tools
Windows
ToolBox.vcproj.ISAS5.Werner.user
ToolBoxTest
// Process.cpp : Implementation of CProcess

#include "stdafx.h"
#include "Processes.h"
#include "Tools\Exception.h"
#include <stdexcept>

CProcess::CProcess() :
    m_name(L""),
    m_pid(0),
    m_threadCount(0),
    m_baseAddress(0),
    m_heapSize(0),
    m_virtualMemory(0),
    m_virtualMemoryCommitted(0),
    m_virtualMemoryReserved(0),
    m_dll(0)
{
}

// CProcess
HRESULT CProcess::FinalConstruct()
{
	return S_OK;
}

void CProcess::FinalRelease()
{
}

STDMETHODIMP CProcess::InterfaceSupportsErrorInfo(REFIID riid)
{
	static const IID* arr[] = 
	{
		&IID_IProcess
	};

	for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
	{
		if (InlineIsEqualGUID(*arr[i],riid))
			return S_OK;
	}
	return S_FALSE;
}

void CProcess::Init(_bstr_t name, long pid, 
                                  long threadCount, 
                                  long baseAddress, 
                                  long heapSize, 
                                  long virtualMemory,
                                  long virtualMemoryCommitted,
                                  long virtualMemoryReserved,
                                  long dll)
{
    m_name = name;
    m_pid = pid;
    m_threadCount = threadCount;
    m_baseAddress = baseAddress;
    m_heapSize = heapSize;
    m_virtualMemory = virtualMemory;
    m_virtualMemoryCommitted = virtualMemoryCommitted;
    m_virtualMemoryReserved = virtualMemoryReserved;
    m_dll = dll;
}

STDMETHODIMP CProcess::get_Name(/*[out, retval]*/ BSTR *value)
{
    try
    {
        Windows::AutoCriticalSection lock(m_lock);

        *value = m_name.copy ();
    } catch (std::exception& err)
    {
        const char* msg = err.what();
        Tools::Exception exception(CLSID_Process, IDS_FAILED);
        return exception.GetException();
    } catch (_com_error& err)
    {
        err = err;
        Tools::Exception exception(CLSID_Process, IDS_FAILED);
        return exception.GetException();
    }

    return S_OK;
}

STDMETHODIMP CProcess::get_Pid(/*[out, retval]*/ LONG *value)
{
    *value = m_pid;
    return S_OK;
}

STDMETHODIMP CProcess::get_ThreadCount(/*[out, retval]*/ LONG *value)
{
    *value = m_threadCount;
    return S_OK;
}

STDMETHODIMP CProcess::get_BaseAddress(/*[out, retval]*/ LONG *value)
{
    *value = m_baseAddress;
    return S_OK;
}

STDMETHODIMP CProcess::get_HeapSize(/*[out, retval]*/ LONG *value)
{
    *value = m_heapSize;
    return S_OK;
}

STDMETHODIMP CProcess::get_VirtualMemory(/*[out, retval]*/ LONG *value)
{
    *value = m_virtualMemory;
    return S_OK;
}

STDMETHODIMP CProcess::get_VirtualMemoryCommitted(/*[out, retval]*/ LONG *value)
{
    *value = m_virtualMemoryCommitted;
    return S_OK;
}

STDMETHODIMP CProcess::get_VirtualMemoryReserved(/*[out, retval]*/ LONG *value)
{
    *value = m_virtualMemoryReserved;
    return S_OK;
}

STDMETHODIMP CProcess::get_DllCount(/*[out, retval]*/ LONG *value)
{
    *value = m_dll;
    return S_OK;
}

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 Code Project Open License (CPOL)

Share

About the Author

Werner Willemsens
Team Leader
Belgium Belgium
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150520.1 | Last Updated 30 Nov 2008
Article Copyright 2008 by Werner Willemsens
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid