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;