Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

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
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
#pragma once

#include <comutil.h>

template <class T>
class CProxy_ICpuLoadEvents : public IConnectionPointImpl<T, &__uuidof(_ICpuLoadEvents), CComDynamicUnkArray>
{
	//Warning this class will  be regenerated by the wizard.
public:
    HRESULT Measurement(LONG CpuLoad)
    {
		T* pT = static_cast<T*>(this);
		int nConnectionIndex;
		int nConnections;
        int nValidConnections = 0;
		CComVariant vars[1];

   		nConnections = m_vec.GetSize();
        for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
        {
			if (m_vec.GetAt(nConnectionIndex)) nValidConnections++;
        }
		for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
		{
			HRESULT hr=S_OK;
			pT->Lock();
			CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);  // Will AddRef() on client
			pT->Unlock();
			IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
			if (pDispatch != NULL)
			{
				vars[0] = _variant_t(CpuLoad);
				DISPPARAMS disp = { vars, NULL, 1, 0 };
        		CComVariant varResult;
		        EXCEPINFO stExcepInfo;
		        unsigned int uiArgErr = 0;
				hr = pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, &stExcepInfo, &uiArgErr);
				if (FAILED(hr))
				{
                    return hr;
				}
			}
		}
        return S_OK;
    }

#ifdef DEBUG
    // This way we can see who subscribes
    STDMETHODIMP Advise(IUnknown *pUnkSink, DWORD *pdwCookie)
	{
		HRESULT hr=S_OK;

		hr = IConnectionPointImpl<T, &__uuidof(_ICpuLoadEvents), CComDynamicUnkArray>::Advise(pUnkSink, pdwCookie);

		return hr;
	}

    // This way we can see who un-subscribes
	STDMETHODIMP Unadvise(DWORD dwCookie)
	{
		HRESULT hr=S_OK;

    	hr = IConnectionPointImpl<T, &__uuidof(_ICpuLoadEvents), CComDynamicUnkArray>::Unadvise(dwCookie);

		return hr;
	}
#endif
};

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.150129.1 | Last Updated 30 Nov 2008
Article Copyright 2008 by Werner Willemsens
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid