Initial
This commit is contained in:
70
test/inproc.cpp
Normal file
70
test/inproc.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#include <test/inproc.hpp>
|
||||
|
||||
void *InProcServerDemoInstantiator::instantiate(IUnknown *pUnkOuter,REFIID riid,void **ppv)
|
||||
{
|
||||
ComResult comResult;
|
||||
InProcServerDemo *pInProcServerDemo;
|
||||
pInProcServerDemo=::new InProcServerDemo(pUnkOuter,riid);
|
||||
if(!pInProcServerDemo)throw Instantiator::NoMemory();
|
||||
comResult=pInProcServerDemo->QueryInterface(riid,ppv);
|
||||
if(comResult.isFailure())
|
||||
{
|
||||
::delete pInProcServerDemo;
|
||||
throw Instantiator::NoInterface();
|
||||
}
|
||||
return pInProcServerDemo;
|
||||
}
|
||||
|
||||
InProcServerDemo::InProcServerDemo(IUnknown *pUnkOuter,REFIID riid)
|
||||
: mValue(0), mRefCount(0)
|
||||
{
|
||||
// getConsole().writeLine("<InProcServerDemo::InProcServerDemo>");
|
||||
if(!IsEqualIID(riid,IID_IDemo))throw Instantiator::NoInterface();
|
||||
}
|
||||
|
||||
InProcServerDemo::~InProcServerDemo()
|
||||
{
|
||||
// getConsole().writeLine("<InProcServerDemo::~InProcServerDemo>");
|
||||
}
|
||||
|
||||
HRESULT __stdcall InProcServerDemo::getValue(int *pvalue)
|
||||
{
|
||||
// getConsole().writeLine("<InProcServerDemo::getValue>");
|
||||
if(!pvalue)return ComResult::InvalidArg;
|
||||
*pvalue=mValue;
|
||||
return ComResult::NoError;
|
||||
}
|
||||
|
||||
HRESULT __stdcall InProcServerDemo::setValue(int value)
|
||||
{
|
||||
// getConsole().writeLine("<InProcServerDemo::setValue>");
|
||||
mValue=value;
|
||||
return ComResult::NoError;
|
||||
}
|
||||
|
||||
HRESULT __stdcall InProcServerDemo::QueryInterface(REFIID riid,void **ppv)
|
||||
{
|
||||
// getConsole().writeLine("<InProcServer::QueryInterface>");
|
||||
*ppv=0;
|
||||
if(IsEqualIID(riid,IID_IUnknown)||IsEqualIID(riid,IID_IDemo))
|
||||
{
|
||||
*ppv=this;
|
||||
AddRef();
|
||||
return NOERROR;
|
||||
}
|
||||
return ComResult::NoInterface;
|
||||
}
|
||||
|
||||
ULONG __stdcall InProcServerDemo::AddRef(void)
|
||||
{
|
||||
// getConsole().writeLine("<InProcServer::AddRef>");
|
||||
return ++mRefCount;
|
||||
}
|
||||
|
||||
ULONG __stdcall InProcServerDemo::Release(void)
|
||||
{
|
||||
// getConsole().writeLine("<InProcServer::Release>");
|
||||
if(0==--mRefCount)::delete this;
|
||||
return mRefCount;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user