⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _icpuloadevents_cp.h

📁 wince6.0平台上的任务管理器,功能类似于windows的任务管理器. In order to develop applications for Windows Mobile 6.x from
💻 H
字号:
#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
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -