PDA

View Full Version : Hibernate - How to



samprp
چهارشنبه 18 مهر 1386, 21:37 عصر
می خوام تو دلفی کامپیوتر رو Hibernate کنم.
چی کار کنم .

Mohammad_Mnt
چهارشنبه 18 مهر 1386, 22:13 عصر
استفاده از تابع ShellExecute و این صفحه (http://www.ss64.com/nt/shutdown.html)

vcldeveloper
پنج شنبه 19 مهر 1386, 03:52 صبح
{-----------------------------------
Description:
Check if hibernation is allowed

Return Values:
TRUE : If Hibernate is supported.
Remarks:
Does not function on WinNT 4.0 or Win95.
History:

------------------------------------}
function HibernateAllowed: Boolean;
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;

{-----------------------------------
Description:
The SetSuspendState function suspends the system by shutting power down.
Depending on the Hibernate parameter,the system either enters a suspend(sleep)
state or hibernation.

Parameters:
Hibernate: If this parameter is TRUE, the system hibernates.
If the parameter is FALSE, the system is suspended.
ForceCritical: If this parameter is TRUE, the system suspends operation immediately;
if it is FALSE, the system broadcasts a PBT_APMQUERYSUSPEND event to
each application to request permission to suspend operation.
DisableWakeEvent: If this parameter is TRUE, the system disables all wake events.
If the parameter is FALSE, any system wake events remain enabled.

Return Values:
TRUE : Function excuted succesfully.
FALSE : Function failed to execute properly.

Remarks:
Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Included in Windows 98 and later.

History:

Author: P. Below
------------------------------------}
function SetSuspendState(Hibernate, ForceCritical, DisableWakeEvent: Boolean): Boolean;
var
_SetSuspendState: TSetSuspendState;
hPowrprof: HMODULE;
begin
Result := False;
hPowrprof := LoadLibrary('POWRPROF.dll');
if hPowrprof <> 0 then
try
_SetSuspendState := getProcAddress(hPowrprof, 'SetSuspendState');
if Assigned(_SetSuspendState) then
Result := _SetSuspendState(Hibernate, ForceCritical, DisableWakeEvent);
finally
FreeLibrary(hPowrprof);
end;
end;

samprp
سه شنبه 24 مهر 1386, 09:42 صبح
آقای Mohammad_Mnt (http://barnamenevis.org/forum/member.php?u=3359) این طور یکه از اون لینک صفحه ی وب معلوم بود پارامتر مربوط به hibarnate کردن فقط در ویندوز 2003 کار می کنه و نه درویندوز های دیگر (مانند XP).:اشتباه:


Description:
Check if hibernation is allowed
آقای علی کشاورز . همان طور که تو کد کامنت زده بود این تابع فقط برای چک کردن اجازه ی hibenate شدن نه برای hibenate کردن . اگه کد hibenate کردن هم می گذاشتین لطف می کردید .
با تشکر

vcldeveloper
سه شنبه 24 مهر 1386, 10:08 صبح
آقای علی کشاورز . همان طور که تو کد کامنت زده بود این تابع فقط برای چک کردن اجازه ی hibenate شدن نه برای hibenate کردن . اگه کد hibenate کردن هم می گذاشتین لطف می کردید
اگر کد را یک بار از ابتدا تا انتها مطالعه کنید، متوجه میشید که دو تابع در کد فوق وجود دارند، یکی برای چک کردن پشتیبانی از Hibernate، و یکی هم برای انجام Hibernate .