Author: Lou Adler How to determine whether the computer supports hibernation, the sleep states Answer: Check if hibernation is allowed 1 function HibernateAllowed: Boolean; 2 type 3 TIsPwrHibernateAllowed = function: Boolean; 4 stdcall; 5 var 6 hPowrprof: HMODULE; 7 IsPwrHibernateAllowed: TIsPwrHibernateAllowed; 8 begin 9 Result := False; 10 if IsNT4Or95 then 11 Exit; 12 hPowrprof := LoadLibrary('powrprof.dll'); 13 if hPowrprof <> 0 then 14 begin 15 try 16 @IsPwrHibernateAllowed := GetProcAddress(hPowrprof, 'IsPwrHibernateAllowed'); 17 if @IsPwrHibernateAllowed <> nil then 18 begin 19 Result := IsPwrHibernateAllowed; 20 end; 21 finally 22 FreeLibrary(hPowrprof); 23 end; 24 end; 25 end; 26 27 //Check if suspend is allowed 28 29 function SuspendAllowed: Boolean; 30 type 31 TIsPwrSuspendAllowed = function: Boolean; 32 stdcall; 33 var 34 hPowrprof: HMODULE; 35 IsPwrSuspendAllowed: TIsPwrSuspendAllowed; 36 begin 37 Result := False; 38 hPowrprof := LoadLibrary('powrprof.dll'); 39 if hPowrprof <> 0 then 40 begin 41 try 42 @IsPwrSuspendAllowed := GetProcAddress(hPowrprof, 'IsPwrSuspendAllowed'); 43 if @IsPwrSuspendAllowed <> nil then 44 begin 45 Result := IsPwrSuspendAllowed; 46 end; 47 finally 48 FreeLibrary(hPowrprof); 49 end; 50 end; 51 end;