开发者

getting difference between two SYSTEMTIME variable

开发者 https://www.devze.com 2023-02-28 22:47 出处:网络
For Example my code is as follows. void main() { SYSTEMTIME LocalTime_Start = { 0 }; GetLocalTime( &LocalTime_Start );

For Example my code is as follows.

void main()

{

       SYSTEMTIME LocalTime_Start = { 0 };

        GetLocalTime( &LocalTime_Start );

        SYSTEMTIME LocalTime_End = { 0 };
        // Some 开发者_JAVA百科program Statements

         GetLocalTime( &LocalTime_End );

         // Now i want difference of two i.e.
         // can i do as following
         SYSTEMTIME localTime_diff = LocalTime_End - LocalTime_Start;
         // guys please let me know how to achieve that asap...thanks a lot in advance
}


Convert both SYSTEMTIME structures to FILETIME using

FILTETIME ft;
::SystemTimeToFileTime(&sysTime, &ft);

Convert FILETIME to ULONGLONG using:

ULARGE_INTEGER uli;
uli.LowPart = ft.dwLowDateTime ;
uli.HighPart= ft.dwHighDateTime;
ULONGLONG uft= uli.QuadPart;

Subtract ULONGLONGs to get time difference in HectoNanoSec

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号