Wednesday, 18 April 2012

Suspend PC

If you need to suspend (hibernate) your PC, you can with Rebol on Windows use the os-sleep function of the following script:
REBOL [
    Title: "LibPowrProf"
    Date: 13-Apr-2012/21:51:25+2:00
    Author: "Oldes"
]
libPowrProf: context [
libPowrProf.dll: load/library %PowrProf.dll
SetSuspendState: make routine! [
Hibernate [integer!]
ForceCritical [integer!]
DisableWakeEvent [integer!]
return: [integer!]
] libPowrProf.dll "SetSuspendState"
set 'os-sleep func[
"Suspends the system by shutting power down"
/hybernate "Use deep (slow) hibernation"
][
SetSuspendState either hybernate [1][0] 1 0
]
]


The library PowrProf.dll is usualy in C:\Windows\System32\, but it will be load automatically.
Than you can use the os-suspend function to suspend your PC.

No comments:

Post a Comment