ReactOS 0.4.16-dev-320-g3bd9ddc
uptime.c
Go to the documentation of this file.
1#define WIN32_LEAN_AND_MEAN
2#include <stdio.h>
3#include <windows.h>
4#include <tchar.h>
5
6int main(int argc, char* argv[])
7{
8 SYSTEMTIME SystemTime;
9 LARGE_INTEGER liCount, liFreq;
10
11 GetLocalTime(&SystemTime);
12
13 if (QueryPerformanceCounter(&liCount) &&
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
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}
static int argc
Definition: ServiceArgs.c:12
BOOL WINAPI QueryPerformanceFrequency(OUT PLARGE_INTEGER lpFrequency)
Definition: perfcnt.c:45
BOOL WINAPI QueryPerformanceCounter(OUT PLARGE_INTEGER lpPerformanceCount)
Definition: perfcnt.c:23
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
int main()
Definition: test.c:6
#define _tprintf
Definition: tchar.h:506
#define argv
Definition: mplay32.c:18
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
WORD wHour
Definition: winbase.h:934
WORD wMinute
Definition: winbase.h:935
int64_t LONGLONG
Definition: typedefs.h:68
LONGLONG QuadPart
Definition: typedefs.h:114
#define _T(x)
Definition: vfdio.h:22