master ohmu/fastfetch-openbsd / src / detection / uptime / uptime_windows.c
ohmu  ·  2026-10-15
 1#include "uptime.h"
 2#include "common/time.h"
 3#include "common/windows/nt.h"
 4
 5const char* ffDetectUptime(FFUptimeResult* result) {
 6    // QueryInterruptTime with Win7 support
 7    uint64_t interruptTime = ffKSystemTimeToUInt64(&SharedUserData->InterruptTime);
 8
 9    result->uptime = interruptTime / 10000; // Convert from 100-nanosecond intervals to milliseconds
10    result->bootTime = ffTimeGetNow() - result->uptime;
11
12    // Alternatively, `NtQuerySystemInformation(SystemTimeOfDayInformation)` reports the boot time directly,
13    // whose result exactly equals what WMI `Win32_OperatingSystem` reports
14    // with much lower accuracy (0.5 seconds)
15
16    return nullptr;
17}