Calculating time by the C++ code

后端 未结 7 783
囚心锁ツ
囚心锁ツ 2021-01-02 22:21

I know this question has been asked few times over SO but none of them is really helping me out, so asking again.

I am using windows xp and running visual studio c++

相关标签:
7条回答
  • 2021-01-02 23:11

    This is working

    #include <windows.h>
    
    SYSTEMTIME startTime;
    GetSystemTime(&startTime);
    WORD startmillis = (startTime.wSecond * 1000) + startTime.wMilliseconds;
    
    // Do some stuff
    
    SYSTEMTIME endTime;
    GetSystemTime(&endTime);
    WORD endmillis = (endTime.wSecond * 1000) + endTime.wMilliseconds;
    
    WORD millis = startmillis - endmillis ;
    
    0 讨论(0)
提交回复
热议问题