#ifndef __GET_TIME_H #define __GET_TIME_H #include "windows.h" // A utility class to get a more accurate time than timeGetTime() class GetTime { public: // Call this before using the function. It won't work in constructor calls though, so you have to call this in Winmain or main and // not use the class in your constructors void Init(void); // Call this or use the #define getTime (below) to get the current time inline unsigned long Time(void) const { LARGE_INTEGER PerfVal; QueryPerformanceCounter(&PerfVal); return (unsigned long)(PerfVal.QuadPart/counts); } GetTime(); ~GetTime() {} // static function because only static functions can access static members static inline GetTime* Instance() {return &I;} private: static GetTime I; LARGE_INTEGER yo; LONGLONG counts; }; #define getTime GetTime::Instance()->Time #endif