//-------------------------------------------------------------------------- // Factory.cpp //-------------------------------------------------------------------------- #include "pch.hxx" #include "dllmain.h" #include "factory.h" #include "session.h" //-------------------------------------------------------------------------- // Pretty //-------------------------------------------------------------------------- #define OBJTYPE0 0 #define OBJTYPE1 OIF_ALLOWAGGREGATION //-------------------------------------------------------------------------- // Global Object Info Table //-------------------------------------------------------------------------- static CClassFactory g_rgFactory[] = { CClassFactory(&CLSID_DatabaseSession, OBJTYPE1, (PFCREATEINSTANCE)CreateDatabaseSession), }; //-------------------------------------------------------------------------- // DllGetClassObject //-------------------------------------------------------------------------- STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) { // Locals HRESULT hr=S_OK; ULONG i; // Bad param if (ppv == NULL) { hr = TrapError(E_INVALIDARG); goto exit; } // No memory allocator if (NULL == g_pMalloc) { hr = TrapError(E_OUTOFMEMORY); goto exit; } // Find Object Class for (i=0; iAddRef(); // Return pObject::IUnknown *ppvObj = (LPVOID)pObject; } // Otherwise else { // Get the interface requested from pObj CHECKHR(hr = pObject->QueryInterface(riid, ppvObj)); } exit: // Cleanup SafeRelease(pObject); // Done Assert(FAILED(hr) ? NULL == *ppvObj : TRUE); return hr; } //-------------------------------------------------------------------------- // CClassFactory::LockServer //-------------------------------------------------------------------------- STDMETHODIMP CClassFactory::LockServer(BOOL fLock) { if (fLock) InterlockedIncrement(&g_cLock); else InterlockedDecrement(&g_cLock); return NOERROR; }