Share via


Interpreting Event Timestamps (Windows Embedded CE 6.0)

1/5/2010

The following sample code shows how you can convert an event timestamp into standard units and display it.

void PrintTimeStamp(
    DWORD dwTimeStamp,   // Timestamp from event header
    DWORD dwFrequency    // Timer frequency from CELID_LOG_MARKER event
    )
{
 __int64 iVal;
    DWORD dwHours, dwMinutes, dwSeconds, dwMilli, dwMicro;

    iVal = (__int64) dwTimeStamp * 1000000;
    iVal = iVal / dwFrequency;

    dwMicro   = (DWORD) ((iVal / (1))                    % 1000);
    dwMilli   = (DWORD) ((iVal / (1000))                 % 1000);
    dwSeconds = (DWORD) ((iVal / (1000 * 1000))          % 60);
    dwMinutes = (DWORD) ((iVal / (1000 * 1000 * 60))     % 60);
    dwHours   = (DWORD) ((iVal / ((__int64) 1000 * 1000 * 60 * 60)));

    printf(TEXT("%2d:%02d:%02d.%03d.%03d"),
           dwHours, dwMinutes, dwSeconds, dwMilli, dwMicro);
}

See Also

Concepts

Logging Event Data
CeLog Event Format