uses Windows;
function IsPwrHibernateAllowed: LongBool; external 'powrprof.dll';
var hToken: Cardinal;
begin
if OpenProcessToken(DWORD(-1), TOKEN_ADJUST_PRIVILEGES, hToken) then
AdjustTokenPrivileges(hToken, False, PTokenPrivileges(PChar(#1#0#0#0#19#0#0#0#0#0#0#0#2#0#0#0))^, 16, nil, PDWORD(0)^);
if not IsPwrHibernateAllowed then
MessageBox(0, 'No está habilitada la hibernación del sistema!', nil, MB_ICONEXCLAMATION)
else if not SetSystemPowerState(False, True) then
MessageBox(0, 'No se ha podido hibernar el equipo!', nil, MB_ICONEXCLAMATION);
end.