Ver Mensaje Individual
  #7  
Antiguo 24-01-2008
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.110
Reputación: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Hola,

Yo utilizo en cierto proyecto una función similar a esta:

Código Delphi [-]
function SystemCanHibernate(): boolean;
resourcestring
  rsDll = 'powrprof.dll';
  rsFunc = 'IsPwrHibernateAllowed';
type
  TFunc = function: boolean; stdcall;
var
  func: TFunc;
  hDll: THandle;
begin
  result := false;
  hDll := LoadLibrary(PChar(rsDll));
  if (hDll <> 0) then
  try
    @func := GetProcAddress(hDll, PChar(rsFunc));
    result := Assigned(func) and func();
  finally
    FreeLibrary(hDll);
  end;
end;

Esta otra función serviría para averiguar si el sistema puede suspenderse:

Código Delphi [-]
function SystemCanSuspend(): boolean;
resourcestring
  rsDll = 'powrprof.dll';
  rsFunc = 'IsPwrSuspendAllowed';
type
  TFunc = function: boolean; stdcall;
var
  func: TFunc;
  hDll: THandle;
begin
  result := false;
  hDll := LoadLibrary(PChar(rsDll));
  if (hDll <> 0) then
  try
    @func := GetProcAddress(hDll, PChar(rsFunc));
    result := Assigned(func) and func();
  finally
    FreeLibrary(hDll);
  end;
end;
__________________
David Esperalta
www.decsoftutils.com
Responder Con Cita