Hola.
No se puede controlar el tiempo transcurrido, pero la función API
CallNtPowerInformation te permitirá conocerlo.
Ejemplo:
Código Delphi
[-]
...
implementation
function CallNtPowerInformation(InformationLevel: DWORD; InPutBuffer: Pointer;
InputBufferSize: ULONG; OutPutBuffer: Pointer;
OutPutBufferSize: ULONG): DWORD; stdcall; external 'PowrProf.dll';
const
LastWakeTime = 14;
LastSleepTime = 15;
STATUS_BUFFER_TOO_SMALL = $C0000023;
STATUS_ACCESS_DENIED = $C0000022;
procedure TForm1.Button1Click(Sender: TObject);
procedure CheckError(const Error: DWORD);
begin
if Error = STATUS_BUFFER_TOO_SMALL then
raise Exception.Create('Buffer muy chico para contener la entrada.');
if Error = STATUS_ACCESS_DENIED then
raise Exception.Create('Acceso denegado');
end;
var
Lst, Lwt : Int64; Err : DWORD;
begin
Err := CallNtPowerInformation(LastWakeTime, nil, 0, @Lwt, SizeOf(Lwt));
CheckError(Err);
Err := CallNtPowerInformation(LastSleepTime, nil, 0, @Lst, SizeOf(Lst));
CheckError(Err);
ShowMessageFmt('%d nanosegundos.',[Round(Lwt/100) - Round(Lst/100)]);
end;
Saludos