Get Time As Second and MicroSecond Since 1970

in #programming3 years ago (edited)

systime.png

DTube video Link

#pragma comment(lib, "ntdll.lib")
#include <Windows.h>
#include <winternl.h>

DWORD64 GetTimeInMicroSecond(PLARGE_INTEGER crntTime)
{
    UINT64 tt;
    tt = crntTime->HighPart;
    tt <<= 32;
    tt |= crntTime->LowPart;
    return (tt/10)- 11644473600000000ULL;
}

// Get Time As Second and MicroSecond Since 1970
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
    LARGE_INTEGER crntTime;
    ULONG seconds = 0,second2;
    DWORD64 microSec;

    NtQuerySystemTime(&crntTime);
    RtlTimeToSecondsSince1970(&crntTime, &seconds);

    microSec = GetTimeInMicroSecond(&crntTime);
    second2 = microSec / 1000000;
    return 0;
}

Please Vote this post if you like it.
Please Follow me if you like my posts.
If you have any questions about this post, ask in comments.
Follow me on :
DTube