Randy,

How do you set up the Ctrl-Break Handler, please?

I would like to hook the handler so as to save before exitting, when Ctrl-Break is pressed.
Posted on 2003-09-30 23:52:34 by V Coder

Randy,

How do you set up the Ctrl-Break Handler, please?

I would like to hook the handler so as to save before exitting, when Ctrl-Break is pressed.


Good Question, I don't remember ever having looked into this.
Anyone else have a comment?
Cheers,
Randy Hyde
Posted on 2003-10-01 11:31:14 by rhyde
The SetConsoleCtrlHandler function adds or removes an application-defined HandlerRoutine function from the list of handler functions for the calling process. If no handler function is specified, the function sets an inheritable attribute that determines whether the calling process ignores CTRL+C signals.

BOOL SetConsoleCtrlHandler(

PHANDLER_ROUTINE pHandlerRoutine, // address of handler function
BOOL fAdd // handler to add or remove
);

BOOL HandlerRoutine(

DWORD dwCtrlType // control signal type
);
Parameters

dwCtrlType

Indicates the type of control signal received by the handler. This value is one of the following:

Signal Description
CTRL_C_EVENT A CTRL+C signal was received, either from keyboard input or from a signal generated by the GenerateConsoleCtrlEvent function.
CTRL_BREAK_EVENT A CTRL+BREAK signal was received, either from keyboard input or from a signal generated by GenerateConsoleCtrlEvent.
CTRL_CLOSE_EVENT A signal that the system sends to all processes attached to a console when the user closes the console (either by choosing the Close command from the console window's System menu, or by choosing the End Task command from the Task List).
CTRL_LOGOFF_EVENT A signal that the system sends to all console processes when a user is logging off. This signal does not indicate which user is logging off, so no assumptions can be made.
CTRL_SHUTDOWN_EVENT A signal that the system sends to all console processes when the system is shutting down.


think thats the one ;)
Posted on 2003-10-01 14:40:09 by evlncrn8