How to get Windows uptime? (Views: 708)
Problem/Question/Abstract: How to get Windows uptime? Answer: Use the following function: function UpTime: string; const ticksperday: integer = 1000 * 60 * 60 * 24; ticksperhour: integer = 1000 * 60 * 60; ticksperminute: integer = 1000 * 60; tickspersecond: integer = 1000; var t: longword; d, h, m, s: integer; begin t := GetTickCount; d := t div ticksperday; dec(t, d * ticksperday); h := t div ticksperhour; dec(t, h * ticksperhour); m := t div ticksperminute; dec(t, m * ticksperminute); s := t div tickspersecond; Result := 'Uptime: ' + IntToStr(d) + ' Days ' + IntToStr(h) + ' Hours ' + IntToStr(m) + ' Minutes ' + IntToStr(s) + ' Seconds'; end; |