// StopwatchClient.cpp : // Defines the entry point for the console application. // // Changes to #include "Stopwatch.h" and #define TIMERSDLL to set path // std::out etc #include #include "Stopwatch.h" // NOTE: The following line will vary depending on // where the Timers.dll is located. #define TIMERSDLL "C:\\CIS630\\Chapter2\\Part1\\Timers\\Debug\\Timers.dll" typedef HRESULT (__stdcall *DLLGETCLASSOBJECT)(REFCLSID rclsid, REFIID riid, LPVOID* ppv); // Instantiates a stopwatch object and returns it by reference HRESULT CreateInstance(void** ppv) { HRESULT hr = E_FAIL; HINSTANCE hinstDll; DLLGETCLASSOBJECT DllGetClassObject; GUID guid; hinstDll = LoadLibrary(TIMERSDLL); if (hinstDll == NULL) std::cout << "Unable to load \"" TIMERSDLL "\"" << std::endl; else { DllGetClassObject = (DLLGETCLASSOBJECT) GetProcAddress(hinstDll, "DllGetClassObject"); if (DllGetClassObject != NULL) hr = DllGetClassObject(guid, guid, ppv); } return hr; } int main(int argc, char* argv[]) { float nElapsedTime; HRESULT hr; IStopwatch* pStopwatch = NULL; hr = CreateInstance((void**) &pStopwatch); if ( !SUCCEEDED(hr) ) std::cout << "ERROR: Unable to create Stopwatch!!"; else { pStopwatch->Start(); pStopwatch->ElapsedTime( &nElapsedTime ); std::cout << "The overhead time is " << nElapsedTime << std::endl; pStopwatch->Release(); pStopwatch = NULL; } return 0; }