- ccomthread2_src.zip
- Shared
- SimpleCOMObject1
- SimpleCOMObject2
- Test Programs
- VBTest
- VCTests
- DemonstrateSTAInterThreadMarshalling
- VCTest01
- main.cpp
- SimpleCOMObject2.tlh
- SimpleCOMObject2.tli
- VBSTACOMObj.tlh
- VBSTACOMObj.tli
- VCTest01.dsp
- VCTest01.dsw
- VCTest02
- VBSTACOMObj
- VBSTACOMObj.cls
- VBSTACOMObj.dll
- VBSTACOMObj.exp
- VBSTACOMObj.lib
- VBSTACOMObj.vbp
- VBSTACOMObj.vbw
|
// SimpleCOMObject1_impl.h : Declaration of the CSimpleCOMObject1
#ifndef __SIMPLECOMOBJECT1_H_
#define __SIMPLECOMOBJECT1_H_
#include "resource.h" // main symbols
#include "ComThread.h"
#include "SimpleCOMObject1CP.h"
/////////////////////////////////////////////////////////////////////////////
// CSimpleCOMObject1
class ATL_NO_VTABLE CSimpleCOMObject1 :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CSimpleCOMObject1, &CLSID_SimpleCOMObject1>,
public ISupportErrorInfo,
public IConnectionPointContainerImpl<CSimpleCOMObject1>,
public IDispatchImpl<ISimpleCOMObject1, &IID_ISimpleCOMObject1, &LIBID_SIMPLECOMOBJECT1Lib>,
public CProxy_ISimpleCOMObject1Events< CSimpleCOMObject1 >
{
friend DWORD WINAPI ThreadFunc_ComThread(LPVOID lpThreadParameter);
public:
CSimpleCOMObject1()
{
}
~CSimpleCOMObject1()
{
}
HRESULT FinalConstruct()
{
m_hExitThread = CreateEvent(NULL, TRUE, FALSE, NULL);
if (m_hExitThread == NULL)
{
return E_FAIL;
}
m_hStartLengthyFunction = CreateEvent(NULL, TRUE, FALSE, NULL);
if (m_hStartLengthyFunction == NULL)
{
return E_FAIL;
}
return S_OK;
}
void FinalRelease()
{
if (m_hExitThread)
{
CloseHandle(m_hExitThread);
m_hExitThread = NULL;
}
if (m_hStartLengthyFunction)
{
CloseHandle(m_hStartLengthyFunction);
m_hStartLengthyFunction = NULL;
}
}
DECLARE_REGISTRY_RESOURCEID(IDR_SIMPLECOMOBJECT1)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CSimpleCOMObject1)
COM_INTERFACE_ENTRY(ISimpleCOMObject1)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(CSimpleCOMObject1)
CONNECTION_POINT_ENTRY(DIID__ISimpleCOMObject1Events)
END_CONNECTION_POINT_MAP()
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
// ISimpleCOMObject1
public:
STDMETHOD(DoLengthyFunction)(/*[in]*/ long lTimeout);
STDMETHOD(Uninitialize)();
STDMETHOD(Initialize)();
protected :
/* ***** Declare an instance of CComThread. ***** */
CComThread m_COMThread;
/* ***** Declare an event object that is set ***** */
/* ***** when we want to terminate the m_COMThread thread. ***** */
HANDLE m_hExitThread;
/* ***** Event object that is set whenever ***** */
/* ***** we want to start the lengthy function. ***** */
HANDLE m_hStartLengthyFunction;
/* ***** long value that indicates to the m_COMThread thread ***** */
/* ***** the timeout value for DoLengthyFunction(). ***** */
long m_lLengthyFunctionTimeout;
protected :
void InitializeComThread();
void UninitializeComThread();
void MarshalEventDispatchInterfacesToComThread();
};
#endif //__SIMPLECOMOBJECT1_H_
|
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.
Lim Bio Liong is a Specialist at a leading Software House in Singapore.
Bio has been in software development for over 10 years. He specialises in C/C++ programming and Windows software development.
Bio has also done device-driver development and enjoys low-level programming. Bio has recently picked up C# programming and has been researching in this area.