windows-nt/Source/XPSP1/NT/admin/services/drizzle/newjob/cunknown.h
2020-09-26 16:20:57 +08:00

47 lines
896 B
C++

template<SIZE_T Offset>
class TrackedClassObject
{
static LONG* GetCounter()
{
return reinterpret_cast<LONG*>( reinterpret_cast<char*>( g_GlobalInfo->m_StatSection ) + Offset );
}
protected:
TrackedClassObject()
{
InterlockedIncrement( GetCounter() );
}
~TrackedClassObject()
{
if (g_ServiceState == MANAGER_INACTIVE)
{
return;
}
InterlockedDecrement( GetCounter() );
}
};
//------------------------------------------------------------------------
template<class T>
class CSimpleExternalIUnknown : public T
{
public:
// IUnknown Methods
STDMETHOD(QueryInterface)(REFIID riid, void **ppvObject);
ULONG _stdcall AddRef(void);
ULONG _stdcall Release(void);
protected:
CSimpleExternalIUnknown();
virtual ~CSimpleExternalIUnknown();
long m_ServiceInstance;
LONG m_refs;
};