PDA

View Full Version : Durée d'exécution de Windows


Matt
20 avril 2003, 20h31
J'aurais besoin pour un de mes programmes de récupérer soit la durée d'exécution de Windows, soit son timestamp de démarrage. Je sais que ces informations sont accessibles, mais je n'ai trouvé nulle part comment les utiliser (ni dans la doc de Delphi, ni dans la doc MSDN).
Si quelqu'un sait comment faire (en Delphi de préférence), je suis très intéressé ...

Xzorg6
20 avril 2003, 21h47
Il me semble que ce soit ca pour Delphi :

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;


Jte promet rien :)

++

Matt
20 avril 2003, 22h02
ouaip. c'est ça ;-) j'avais fini par trouver entre temps dans la doc MSDN : "The GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started."
Merci quand même :-)

nonoghost
20 avril 2003, 23h41
surement en retard, mais j'ai pensé a BGINFO disponible sur www.sysinternals.com (http://www.sysinternals.com)
qui affiche un tas de choses sur le systeme via le background de votre bureau....