Ver Mensaje Individual
  #2  
Antiguo 24-01-2019
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
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;   // unidad 100 nanosegundos.
  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
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita