96 lines
2.3 KiB
C++
96 lines
2.3 KiB
C++
#include <com/com.hpp>
|
|
#include <test/ipdemo.hpp>
|
|
|
|
|
|
InProcServerDemo::InProcServerDemo(IUnknown *pUnkOuter,REFIID riid,Console &winConsole)
|
|
//: InProcServer(pUnkOuter,riid,winConsole), mValue(0)
|
|
: mValue(0), mRefCount(0), mWinConsole(winConsole)
|
|
{
|
|
getConsole().writeLine("<InProcServerDemo::InProcServerDemo>");
|
|
if(!IsEqualIID(riid,IID_IDemo))throw InProcServerDemo::InProcServerDemoNoInterface();
|
|
}
|
|
|
|
InProcServerDemo::~InProcServerDemo()
|
|
{
|
|
getConsole().writeLine("<InProcServerDemo::~InProcServerDemo>");
|
|
}
|
|
|
|
REFIID InProcServerDemo::getREFIID(void)
|
|
{
|
|
getConsole().writeLine("<InProcServerDemo::getREFIID>");
|
|
return IID_IDemo;
|
|
}
|
|
|
|
void *InProcServerDemo::getInstance(void)
|
|
{
|
|
getConsole().writeLine("<InProcServerDemo::getInstance>");
|
|
return (void*)this;
|
|
}
|
|
|
|
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,getREFIID()))
|
|
{
|
|
*ppv=getInstance();
|
|
// *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;
|
|
}
|
|
|
|
|
|
#if 0
|
|
HRESULT __stdcall InProcServerDemo::QueryInterface(REFIID riid,void **ppv)
|
|
{
|
|
getConsole().writeLine("<InProcServerDemo::QueryInterface>");
|
|
return InProcServer::QueryInterface(riid,ppv);
|
|
}
|
|
|
|
ULONG __stdcall InProcServerDemo::AddRef(void)
|
|
{
|
|
getConsole().writeLine("<InProcServerDemo::AddRef>");
|
|
return InProcServer::AddRef();
|
|
}
|
|
|
|
ULONG __stdcall InProcServerDemo::Release(void)
|
|
{
|
|
getConsole().writeLine("<InProcServerDemo::Release>");
|
|
return InProcServer::Release();
|
|
}
|
|
#endif
|
|
|
|
Console &InProcServerDemo::getConsole(void)
|
|
{
|
|
return mWinConsole;
|
|
} |