allow_break() and check_break() don't work on Windows XP SP3 (ie. allow_break(0) do not prevent a program from being terminated with ctrl-break key press).
There is some code I wrote to implement functionality declared in the manual:
include std/console.e
include std/dll.e
constant kernel32 = open_dll("kernel32.dll")
constant SetConsoleCtrlHandler =
define_c_func(kernel32,"SetConsoleCtrlHandler", {C_LONG,C_LONG},C_LONG)
integer breaks
function CtrlHandler(atom ct)
breaks += 1
return 1
end function
procedure allow_break(integer i)
breaks = 0
c_func(SetConsoleCtrlHandler,{call_back(routine_id("CtrlHandler")), not i})
end procedure
function check_break()
integer b = breaks
breaks = 0
return b
end function
puts(1,"Press Ctrl+Break or try to close the console window\n")
integer k
allow_break(0)
while 1 do
if check_break() then
puts(1,"Break\n")
exit
end if
end while
any_key()