[][src]Function winconsole::console::set_ctrl_handler

pub fn set_ctrl_handler(
    handler: Option<unsafe extern "system" fn(_: u32) -> i32>,
    add: bool
) -> WinResult<()>

Adds or removes a handler routine from the console.

Arguments

Examples

unsafe extern "system" fn handler(event_type: u32) -> i32 {
    if event_type == 0 {
        println!("CTRL + C pressed.");
        return 1; // TRUE
    }
    return 0; // FALSE
}
console::set_ctrl_handler(Some(handler), true).unwrap();

Errors

See

HandlerRoutine.