首页  编辑  

系统是否支持休眠和挂起

Tags: /超级猛料/OS.操作系统/Control Panel.控制面板/   Date Created:

系统是否支持休眠和挂起

determine whether the computer supports hibernation, the sleep states?

Author: Thomas Stutz  

//**********************************************************************

// Check if hibernation is allowed

//*********************************************************************

function HibernateAllowed: Boolean;

type

 TIsPwrHibernateAllowed = function: Boolean;

 stdcall;

var

 hPowrprof: HMODULE;

 IsPwrHibernateAllowed: TIsPwrHibernateAllowed;

begin

 Result := False;

 if IsNT4Or95 then Exit;

 hPowrprof := LoadLibrary('powrprof.dll');

 if hPowrprof <> 0 then

 begin

   try

     @IsPwrHibernateAllowed := GetProcAddress(hPowrprof, 'IsPwrHibernateAllowed');

     if @IsPwrHibernateAllowed <> nil then

     begin

       Result := IsPwrHibernateAllowed;

     end;

   finally

     FreeLibrary(hPowrprof);

   end;

 end;

end;

//**********************************************************************

// Check if suspend is allowed

//**********************************************************************

function SuspendAllowed: Boolean;

type

 TIsPwrSuspendAllowed = function: Boolean;

 stdcall;

var

 hPowrprof: HMODULE;

 IsPwrSuspendAllowed: TIsPwrSuspendAllowed;

begin

 Result := False;

 hPowrprof := LoadLibrary('powrprof.dll');

 if hPowrprof <> 0 then

 begin

   try

     @IsPwrSuspendAllowed := GetProcAddress(hPowrprof, 'IsPwrSuspendAllowed');

     if @IsPwrSuspendAllowed <> nil then

     begin

       Result := IsPwrSuspendAllowed;

     end;

   finally

     FreeLibrary(hPowrprof);

   end;

 end;

end;