// Timers.cpp : Implementation of DLL Exports. #include #include "StopwatchClassFactory.h" #include "timers_i.c" // Global lock counter used by IClassFactory::LockServer() long g_nServerLockCount = 0; //////////////////////////////////////////////////////////////////// // DLL Entry Point extern "C" BOOL __stdcall DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) { return TRUE; // All is well } //////////////////////////////////////////////////////////////////// // Determines whether the DLL can be unloaded yet extern "C" HRESULT __stdcall DllCanUnloadNow(void) { return (g_nServerLockCount == 0 ) ? S_OK : S_FALSE; } //////////////////////////////////////////////////////////////////// // Returns a component object class factory to the caller extern "C" HRESULT __stdcall DllGetClassObject( REFCLSID rclsid, REFIID riid, LPVOID* ppv) { HRESULT hr; if (rclsid == CLSID_Stopwatch) { CStopwatchClassFactory* pStopwatchClassFactory = new CStopwatchClassFactory; hr = pStopwatchClassFactory->QueryInterface(riid, ppv); if(FAILED(hr)) { delete pStopwatchClassFactory; } } else hr = E_NOTIMPL; return hr; }