// -------------------------------------------------------------------------------- // Factory.cpp // Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved // Steven J. Bailey // -------------------------------------------------------------------------------- #include "pch.hxx" #include "dllmain.h" #include "factory.h" #include "msoert.h" #include "mimeole.h" #include "envhost.h" // -------------------------------------------------------------------------------- // Pretty // -------------------------------------------------------------------------------- #define OBJTYPE0 0 #define OBJTYPE1 OIF_ALLOWAGGREGATION // -------------------------------------------------------------------------------- // Global Object Info Table // -------------------------------------------------------------------------------- static CClassFactory g_rgFactory[] = { CClassFactory(&CLSID_GWEnvelopeHost, OBJTYPE0, (PFCREATEINSTANCE)GWNote_CreateInstance) }; // -------------------------------------------------------------------------------- // 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; } // -------------------------------------------------------------------------------- // GWNote_CreateInstance // -------------------------------------------------------------------------------- HRESULT GWNote_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown) { // Invalid Arg Assert(ppUnknown); // Initialize *ppUnknown = NULL; // Create me CEnvHost *pNew= new CEnvHost(pUnkOuter); if (NULL == pNew) return (E_OUTOFMEMORY); // Cast to unknown *ppUnknown = SAFECAST(pNew, IMsoEnvelopeHost *); // Done return S_OK; }