Реферат: Перехват методов COM интерфейсов
public:
// реализация IStream
STDMETHOD(Seek)(_LARGE_INTEGER dlibMove, ULONG dwOrigin,
_ULARGE_INTEGER * plibNewPosition)
{
return m_spStm->Seek(dlibMove, dwOrigin, plibNewPosition);
}
// остальные методы реализованы аналогично Seek
...
STDMETHOD(Stat)(tagSTATSTG * pstatstg, ULONG grfStatFlag)
{
HRESULT hr = m_spStm->Stat(pstatstg, grfStatFlag);
if( SUCCEEDED(hr) && (grfStatFlag & STATFLAG_NONAME) == 0)
{
pstatstg->pwcsName = AtlAllocTaskWideString(m_name);
}
return hr;
}
private:
friend HRESULT CreateStreamOnHGlobal2(HGLOBAL ,BOOL ,LPOLESTR, LPSTREAM*);
HRESULT init(HGLOBAL hGlobal,BOOL fDeleteOnRelease, LPOLESTR name)
{
m_spStm.Release();
HRESULT hr = CreateStreamOnHGlobal(hGlobal, fDeleteOnRelease, &m_spStm);
if(SUCCEEDED(hr))
{
m_name = name;
}
return hr;