#pragma comment(lib, "ntdll.lib")
#include
#include
#define SystemTimeOfDayInformation 3
typedef struct _SYS_TIMEOFDAY_INFO {
LARGE_INTEGER BootTime;
LARGE_INTEGER CurrentTime;
LARGE_INTEGER TimeZoneBias;
ULONG TimeZoneId;
ULONG Reserved;
ULONGLONG BootTimeBias;
ULONGLONG SleepTimeBias;
} SYS_TIMEOFDAY_INFO, *PSYS_TIMEOFDAY_INFO;
BOOL GetCrntTime(PLARGE_INTEGER crntTime)
{
LARGE_INTEGER ret;
SYS_TIMEOFDAY_INFO sysTimeInfo;
ULONG cbNeeded = sizeof(sysTimeInfo);
if (NT_SUCCESS(NtQuerySystemInformation(SystemTimeOfDayInformation, &sysTimeInfo, cbNeeded, &cbNeeded)))
{
*crntTime = sysTimeInfo.CurrentTime;
return TRUE;
}
else return FALSE;
}
// Alternative Ways to get system time
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
FILETIME fileTime;
SYSTEMTIME sysTime,t2;
//Method1: Kernel32
//GetSystemTimeAsFileTime(&fileTime);
//Method2 : ntdll
//NtQuerySystemTime(&fileTime);
//Method3 : ntdll
GetCrntTime(&fileTime);
FileTimeToSystemTime(&fileTime, &sysTime);
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