Hasty Briefsbeta

Bilingual

DOS: Determining System Uptime

2 days ago
  • The author plans to use Windows NT4 for Advent of Code and needed a simple uptime tool.
  • Existing method `net statistics server | more` is cumbersome, so a thin wrapper around `GetTickCount()` was made for Windows.
  • An OS/2 version wraps `DosQuerySysInfo()`, and DOS is tricky because it doesn't track uptime explicitly.
  • Mark Aitchison's 1997 Pascal program `UPTIME.PAS` uses `GetFTime` on `NUL`, but actually reads stdin (handle 0) modification time.
  • A C program using `_dos_getftime(0)` works but breaks with `ctty` or in DOSBox.
  • Javier Gutierrez Chamorro's `UPTIMEC` uses CMOS Real-Time Clock alarm time, requiring `uptime /R` in `autoexec.bat` for correct values.
  • An alternative is to store boot time in a file, offering portability but cluttering the filesystem.
  • The author chose the `_dos_getftime(0)` approach for simplicity since they only need occasional uptime checks.