[WINLOGON]
[reactos.git] / rosapps / applications / cmdutils / uptime / uptime.c
1 #define WIN32_LEAN_AND_MEAN
2 #include <stdio.h>
3 #include <windows.h>
4 #include <tchar.h>
5
6 int main(int argc, char* argv[])
7 {
8 SYSTEMTIME SystemTime;
9 LARGE_INTEGER liCount, liFreq;
10
11 GetLocalTime(&SystemTime);
12
13 if (QueryPerformanceCounter(&liCount) &&
14 QueryPerformanceFrequency(&liFreq))
15 {
16 LONGLONG TotalSecs = liCount.QuadPart / liFreq.QuadPart;
17 LONGLONG Days = (TotalSecs / 86400);
18 LONGLONG Hours = ((TotalSecs % 86400) / 3600);
19 LONGLONG Mins = ((TotalSecs % 86400) % 3600) / 60;
20 LONGLONG Secs = ((TotalSecs % 86400) % 3600) % 60;
21
22 #ifdef LINUX_OUTPUT
23 UNREFERENCED_PARAMETER(Secs);
24 _tprintf(_T(" %.2u:%.2u "), SystemTime.wHour, SystemTime.wMinute);
25 _tprintf(_T("up %I64u days, %I64u:%I64u\n"), Days, Hours, Mins); /*%.2I64u secs*/
26 #else
27 _tprintf(_T("System Up Time:\t\t%I64u days, %I64u Hours, %I64u Minutes, %.2I64u Seconds\n"),
28 Days, Hours, Mins, Secs);
29 #endif
30 return 0;
31 }
32
33 return -1;
34 }