I've been looking around and have searched these forums for a way of getting the system uptime but could'nt find anything. If you can help, please do, thanks.
Printable View
I've been looking around and have searched these forums for a way of getting the system uptime but could'nt find anything. If you can help, please do, thanks.
Look into GetTickCount().
GetTickCount() returns time since Windows started in milliseconds. But what I've written is'nt very good:Gives me this:Code:DWORD ms = GetTickCount();
DWORD secs, mins, hours, days;
secs=ms/1000;
mins=secs/60;
hours=mins/60;
days=hours/24;
Which is not what I want. I want to end up with something which outputs something like "2 days, 4 hrs, 38 mins" - please help! Thanks.Quote:
Milliseconds: 188299656
Seconds: 188299
Minutes: 3138
Hours: 52
Days: 2
just a little bit of extra math chief. I'll give you a hint. what's the number of hours when you subtract (days * 24) from it?
Look up the floor function in math.h/cmath. After that, you are going to want to start with the greatest one (days) and work your way down. Every time you take a value, subtract the number of milliseconds from the total.
o k i c.
But it seems I can't think, it's all null. Like, with your help, I came up with:
hours-days*24
to give me the hours i was after. But how do i get the minutes? Thanks
days=miliseconds/(1000*60*60*24);
miliseconds-=days*1000*60*60*24;
//do the rest the same way