Click here to Skip to main content
12,292,976 members (64,932 online)
Click here to Skip to main content

Stats

73.4K views
5.6K downloads
73 bookmarked
Posted

Task Manager for Windows Mobile and Windows CE

, 30 Nov 2008 CPOL
Source code for writing your own Task Manager for Windows Mobile or Windows CE based devices
Documents and Settings
Werner
My Documents
The CodeProject
CETaskManager_V2
CETaskManager.CAB
CETaskManager
CAB
TaskManager.vddproj
CEChart
bin
Release
CE
CEchart.dll
CEchart.pdb
CETaskManager
Properties
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
// System.cpp : Implementation of CSystem

#include "stdafx.h"
#include "System.h"
#include <stdexcept>
#include "Tools\Exception.h"
#include "Windows\Handle.h"

CSystem::CSystem()
{
    Update();
}

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

void CSystem::FinalRelease()
{
}

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

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

STDMETHODIMP CSystem::Update(void)
{
    {
        // Make sure this happens thread-safe
        Windows::AutoCriticalSection lock(m_lock);

        m_memoryStatus.dwLength = sizeof(MEMORYSTATUS);
        GlobalMemoryStatus(&m_memoryStatus);
    }

    return S_OK;
}

STDMETHODIMP CSystem::get_PhysicalMemoryTotal(/*[out, retval]*/ LONG *value)
{
    *value = m_memoryStatus.dwTotalPhys;
    return S_OK;
}

STDMETHODIMP CSystem::get_PhysicalAvailable(/*[out, retval]*/ LONG *value)
{
    *value = m_memoryStatus.dwAvailPhys;
    return S_OK;
}

STDMETHODIMP CSystem::get_PageFileTotal(/*[out, retval]*/ LONG *value)
{
    *value = m_memoryStatus.dwTotalPageFile;
    return S_OK;
}

STDMETHODIMP CSystem::get_PageFileAvailable(/*[out, retval]*/ LONG *value)
{
    *value = m_memoryStatus.dwAvailPageFile;
    return S_OK;
}

STDMETHODIMP CSystem::get_VirtualMemoryTotal(/*[out, retval]*/ LONG *value)
{
    *value = m_memoryStatus.dwTotalVirtual;
    return S_OK;
}

STDMETHODIMP CSystem::get_VirtualMemoryAvailable(/*[out, retval]*/ LONG *value)
{
    *value = m_memoryStatus.dwAvailVirtual;
    return S_OK;
}

STDMETHODIMP CSystem::EndProcess(/*[in]*/ LONG Pid, /*[out, retval]*/ VARIANT_BOOL *result)
{
    BOOL success = FALSE;
    try
    {
        Windows::Handle processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Pid);
        success = TerminateProcess(processHandle, 0);
    } catch (...)
    {
    }

    *result = (success != FALSE) ? VARIANT_TRUE : VARIANT_FALSE;

    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

You may also be interested in...

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