SetConsoleCtrlHandler function Null safety kernel32

int SetConsoleCtrlHandler(
  1. Pointer<NativeFunction<HandlerProc>> HandlerRoutine,
  2. int Add
)

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

BOOL WINAPI SetConsoleCtrlHandler(
  _In_opt_ PHANDLER_ROUTINE HandlerRoutine,
  _In_     BOOL             Add
);

Implementation

int SetConsoleCtrlHandler(
    Pointer<NativeFunction<HandlerProc>> HandlerRoutine, int Add) {
  final _SetConsoleCtrlHandler = _kernel32.lookupFunction<
      Int32 Function(
          Pointer<NativeFunction<HandlerProc>> HandlerRoutine, Int32 Add),
      int Function(Pointer<NativeFunction<HandlerProc>> HandlerRoutine,
          int Add)>('SetConsoleCtrlHandler');
  return _SetConsoleCtrlHandler(HandlerRoutine, Add);
}