Last active
August 29, 2015 14:05
-
-
Save bedefaced/3615bbba431496593231 to your computer and use it in GitHub Desktop.
uptime utility for Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <windows.h> | |
DWORD ticks; | |
int days, hours, mins, secs; | |
void main() | |
{ | |
ticks = GetTickCount() / 1000; | |
days = ticks / (24 * 60 * 60); | |
ticks -= days * 24 * 60 * 60; | |
hours = ticks / (60 * 60); | |
ticks -= hours * 60 * 60; | |
mins = ticks / 60; | |
ticks -= mins * 60; | |
secs = ticks; | |
printf("\r\n\r\nUPTIME : %d days, %d hours, %d mins, %d secs.\r\n\r\n", days, hours, mins, secs); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment