static ULONG __stdcall CF_AddRef(IClassFactory *this) {
InterlockedIncrement(&g_dwObjectCount);
return(1);
}
static HRESULT __stdcall CF_QueryInterface(IClassFactory *this, REFIID riid, void **ppv) {
if (IsEqualIID(riid, &IID_IUnknown) ||
IsEqualIID(riid, &IID_IClassFactory)) {
this->lpVtbl->AddRef(this);
*ppv = this;
return(NOERROR);
}
*ppv = NULL;
return(E_NOINTERFACE);
}
static ULONG __stdcall CF_Release(IClassFactory *this) {
return(InterlockedDecrement(&g_dwObjectCount));
}
static HRESULT __stdcall CF_CreateInstance(IClassFactory *this, IUnknown *punkOuter, REFIID riid, void **ppv) {
HRESULT hr;
register IStep1 *thisObj;
*ppv = NULL;
if (punkOuter)
hr = CLASS_E_NOAGGREGATION;
else {
if(thisObj = (IStep1 *)GlobalAlloc(GMEM_FIXED, sizeof(CStep1))) {
thisObj->lpVtbl = &IStep1_Vtbl;
((CStep1 *)thisObj)->dwRefCount = 1;
((CStep1 *)thisObj)->szString[0] = 0;
hr = thisObj->lpVtbl->QueryInterface(thisObj, riid, ppv);
thisObj->lpVtbl->Release(thisObj);
if (!hr) InterlockedIncrement(&g_dwObjectCount);
}
else {
hr = E_OUTOFMEMORY;
}
}
return(hr);
}
static HRESULT __stdcall CF_LockServer(IClassFactory *this,
BOOL flock) {
if (flock) InterlockedIncrement(&g_dwLockCount);
else InterlockedDecrement(&g_dwLockCount);
return(NOERROR);
} |