How can I get Windows boot time in C++ with some WinAPI functions? I am currently using the command \"systeminfo\", but I\'m looking for a more proper solution.
I've checked at how Task Manager does it, and turns out it uses the ZwQuerySystemInformation(SystemTimeOfDayInformation, ...)
function, which receives the SYSTEM_TIMEOFDAY_INFORMATION
structure.
typedef struct _SYSTEM_TIMEOFDAY_INFORMATION {
LARGE_INTEGER BootTime;
LARGE_INTEGER CurrentTime;
LARGE_INTEGER TimeZoneBias;
ULONG TimeZoneId;
ULONG Reserved;
ULONGLONG BootTimeBias;
ULONGLONG SleepTimeBias;
} SYSTEM_TIMEOFDAY_INFORMATION, *PSYSTEM_TIMEOFDAY_INFORMATION;
(source)
BootTime
is what you're looking for.
For something more documented, I think GetTickCount64
will do.