SetConsoleCtrlHandler function kernel32

Win32Result<bool> SetConsoleCtrlHandler(
  1. Pointer<NativeFunction<PHANDLER_ROUTINE>>? handlerRoutine,
  2. bool add
)

Adds or removes an application-defined HandlerRoutine function from the list of handler functions for the calling process.

To learn more, see learn.microsoft.com/windows/console/setconsolectrlhandler.

Implementation

Win32Result<bool> SetConsoleCtrlHandler(
  Pointer<NativeFunction<PHANDLER_ROUTINE>>? handlerRoutine,
  bool add,
) {
  final result_ = SetConsoleCtrlHandler_Wrapper(
    handlerRoutine ?? nullptr,
    add ? TRUE : FALSE,
  );
  return Win32Result(value: result_.value.i32 != FALSE, error: result_.error);
}