Using timers in windows programming is common in nature. Lot of situations like calculating the time difference, calculating the execution time of a procedure or an operation etc.

Microsoft provides a lot of methods for calculating time, by using common,  SetTimer() and KillTimer() methods and High-Resolution Timer methods like QueryPerformanceCounter() and QueryPerformanceFrequency()

Here I’m just describing how to calculate the time difference by using the Microsoft High-Resolution timer methods.

    LARGE_INTEGER m_lnStart;
    LARGE_INTEGER m_lnEnd;
    LARGE_INTEGER m_lnFreq;

    QueryPerformanceFrequency(&m_lnFreq);//Retrieves the frequency of the high-resolution performance counter

    QueryPerformanceCounter( &m_lnStart);//Retrieves the current value of the high-resolution performance counter
    //Some Operations..
    QueryPerformanceCounter( &m_lnEnd );

    __int64 nDiff(0) ;
    double dMircoSecond( 0 ) ;
    if( m_lnStart.QuadPart !=0 && m_lnEnd.QuadPart != 0)
        dMircoSecond = (double)(m_lnFreq.QuadPart/1000000);
        nDiff = m_lnEnd.QuadPart-m_lnStart.QuadPart ;
        dMircoSecond = nDiff/dMircoSecond;

Now you got the time difference in Microsecond..

What we need above this.. 🙂

Thanks to Microsoft®..