- ccomthread_src.zip
- LegacyCOMObject1
- Shared
- SimpleCOMObject1
- SimpleCOMObject2
- Test Programs
- VBTest
- VCTests
- DemonstrateDefaultSTA
- VCTest01
- main.cpp
- SimpleCOMObject2.tlh
- SimpleCOMObject2.tli
- VCTest01.dsp
- VCTest01.dsw
- VCTest02
- main.cpp
- SimpleCOMObject2.tlh
- SimpleCOMObject2.tli
- VCTest02.dsp
- VCTest02.dsw
- DemonstrateExeServerSTA
- Client
- VCTest01
- Implementation
- ExeServerImpl
- Interface
- ExeServerInterfaces
- DemonstrateLegacySTA
- VCTest01
- LegacyCOMObject1.tlh
- LegacyCOMObject1.tli
- main.cpp
- VCTest01.dsp
- VCTest01.dsw
- VCTest02
- DemonstrateNoMessageLoop
- VCTest01
- main.cpp
- SimpleCOMObject2.tlh
- SimpleCOMObject2.tli
- VCTest01.dsp
- VCTest01.dsw
- DemonstrateSTA
- VCTest01
- main.cpp
- SimpleCOMObject2.tlh
- SimpleCOMObject2.tli
- VCTest01.dsp
- VCTest01.dsw
|
#include "ExeObj01.h"
#include <stdio.h>
CExeObj01::CExeObj01()
{
}
CExeObj01::~CExeObj01()
{
}
STDMETHODIMP CExeObj01::QueryInterface(REFIID riid, void** ppvObject)
{
if (riid == IID_IUnknown || riid == IID_IExeObj01)
{
*ppvObject = (IExeObj01*)this;
((CReferenceCountedObject*)this) -> AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
// IUnknown method.
STDMETHODIMP_(ULONG) CExeObj01::AddRef()
{
return CReferenceCountedObject::AddRef();
}
// IUnknown method.
STDMETHODIMP_(ULONG) CExeObj01::Release()
{
return CReferenceCountedObject::Release();
}
STDMETHODIMP CExeObj01::TestMethod1()
{
TCHAR szMessage[256];
sprintf (szMessage, "0x%X", GetCurrentThreadId());
::MessageBox(NULL, szMessage, "CExeObj01::TestMethod1()", MB_OK);
return S_OK;
}
CExeObj01_Factory::CExeObj01_Factory()
{
}
CExeObj01_Factory::~CExeObj01_Factory()
{
}
// IUnknown method. Overridde QueryInterface() method.
STDMETHODIMP CExeObj01_Factory::QueryInterface(REFIID riid, void** ppvObject)
{
if (riid == IID_IUnknown)
{
CReferenceCountedObject* pCReferenceCountedObject = (CReferenceCountedObject*)this;
*ppvObject = (IUnknown*)pCReferenceCountedObject;
((CReferenceCountedObject*)this) -> AddRef();
return S_OK;
}
if (riid == IID_IClassFactory)
{
*ppvObject = (IClassFactory*)this;
((CReferenceCountedObject*)this) -> AddRef();
return S_OK;
}
*ppvObject = NULL;
return E_NOINTERFACE;
}
// IUnknown method.
STDMETHODIMP_(ULONG) CExeObj01_Factory::AddRef()
{
return CClassFactory::AddRef();
}
// IUnknown method.
STDMETHODIMP_(ULONG) CExeObj01_Factory::Release()
{
return CClassFactory::Release();
}
// IClassFactory method.
STDMETHODIMP CExeObj01_Factory::CreateInstance
(
IUnknown __RPC_FAR *pUnkOuter,
REFIID riid,
void __RPC_FAR *__RPC_FAR *ppvObject
)
{
CExeObj01* pCExeObj01 = NULL;
// Initialise the receiver.
*ppvObject = NULL;
if (pUnkOuter != NULL)
{
return CLASS_E_NOAGGREGATION;
}
// Create an instance of the component.
pCExeObj01 = new CExeObj01;
if (pCExeObj01 == NULL)
{
return E_OUTOFMEMORY;
}
pCExeObj01 -> QueryInterface (riid, ppvObject);
pCExeObj01 -> Release();
return S_OK;
}
// IClassFactory method.
STDMETHODIMP CExeObj01_Factory::LockServer
(
BOOL fLock
)
{
return CClassFactory::LockServer(fLock);
}
|
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.