Skip to content

Instantly share code, notes, and snippets.

@bedefaced
Last active August 29, 2015 14:05
Show Gist options
  • Save bedefaced/3615bbba431496593231 to your computer and use it in GitHub Desktop.
Save bedefaced/3615bbba431496593231 to your computer and use it in GitHub Desktop.
uptime utility for Windows
#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