cli-apt.cpp

来自「inside com的源代码」· C++ 代码 · 共 72 行

CPP
72
字号
#include <windows.h> 
#include <stdlib.h>
#include <objbase.h>
#include <assert.h>

#include "Iface.h"
#include "Apart.h"
#include "Cli-Apt.h"

///////////////////////////////////////////////////////////
//
// Constructor
//
CClientApartment::CClientApartment() 
{
	m_pIX = NULL ;
} 

///////////////////////////////////////////////////////////
//
// Destructor
//
CClientApartment::~CClientApartment()
{
	if (m_pIX != NULL)
	{
		m_pIX->Release() ;
	}
}


///////////////////////////////////////////////////////////
//
// CreateTheComponent
//
HRESULT CClientApartment::CreateComponentOnThread(const CLSID& clsid,
                                                  const IID& iid,
                                                  IUnknown** ppI) 
{
	HRESULT hr = ::CoCreateInstance(clsid,
	                                NULL, 
	                                CLSCTX_INPROC_SERVER, 
	                                iid, 
	                                (void**)ppI) ;
	if (SUCCEEDED(hr))
	{
		// Query for the IX interface to use in WorkerFunction.
		hr = (*ppI)->QueryInterface(IID_IX, (void**)&m_pIX) ;
		if (FAILED(hr))
		{
			// If we can't use it, don't let anybody use it.
			(*ppI)->Release() ;
			return E_FAIL ;
		}
		
	}
	
	return hr ;
}

///////////////////////////////////////////////////////////
//
// WorkerFunction - This function is called by the worker thread.
//
void CClientApartment::WorkerFunction()
{
	if (m_pIX)
	{
		m_pIX->Tick() ;
	}
}

⌨️ 快捷键说明

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