13 ошибок
#include "stdafx.h"
#include <iostream>
#include <ole.h>
#include <Unknwn.h>
extern "C" __declspec(dllexport) const IID IID_IX = { 0xb3d5176e, 0x592a, 0x4fb5, 0xa866, 0x802ca839f6b3 };
extern "C" __declspec(dllexport) const IID IID_IY = { 0xf4ee8427, 0x53d3, 0x4595, 0xac0d, 0x15d5856e9ba0 };
extern "C" __declspec(dllexport) __interface IX : IUnknown
{
virtual std::string _stdcall FxMessage() = 0;
};
extern "C" __declspec(dllexport) __interface IY : IUnknown
{
virtual std::string _stdcall FyMessage() = 0;
};
class CA : public IX, public IY
{
private:
int m_cRef;
public:
CA();
HRESULT _stdcall QueryInterface(const IID &iid, void** ppv);
ULONG _stdcall AddRef();
ULONG _stdcall Release();
std::string _stdcall FxMessage();
std::string _stdcall FyMessage();
};
CA::CA()
{
m_cRef = 0;
}
HRESULT _stdcall CA::QueryInterface(const IID &iid, void** ppv)
{
if (iid == IID_IX)
*ppv = static_cast<IX*>(this);
else if (iid == IID_IY)
*ppv = static_cast<IY*>(this);
else if (iid == IID_IUnknown)
*ppv = static_cast<IUnknown*>(static_cast<IX*>(this));
else
{
*ppv = NULL;
return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 512);
}
static_cast<IUnknown*>(static_cast<IX*>(this))->AddRef();
return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_ITF, 1);
}
ULONG _stdcall CA::AddRef()
{
return ++m_cRef;
}
ULONG _stdcall CA::Release()
{
if ((--m_cRef) == 0)
delete this;
return m_cRef;
}
std::string _stdcall CA::FxMessage()
{
return "FxMessage";
}
std::string _stdcall CA::FyMessage()
{
return "FyMessage";
}
extern "C" __declspec(dllexport) IUnknown* CreateInstance()
{
IUnknown* pI = static_cast<IUnknown*>(static_cast<void*>(new CA));
pI->AddRef();
return pI;
}