5

For Example my code is as follows.

void main()

{

       SYSTEMTIME LocalTime_Start = { 0 };

        GetLocalTime( &LocalTime_Start );

        SYSTEMTIME LocalTime_End = { 0 };
        // Some 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
}
skaffman
  • 398,947
  • 96
  • 818
  • 769
Kundan
  • 291
  • 1
  • 3
  • 8

1 Answers1

3

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

Lior Kogan
  • 19,919
  • 6
  • 53
  • 85
  • 1
    Not applicable in this case but SystemTimeToFileTime will fail if the input SYSTEMTIME represents ZERO time (that is all its members are 0). – TheArtTrooper Jan 19 '12 at 10:00