Advertisement
canezzy

Untitled

Jan 21st, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. // Declare the SetConsoleCtrlHandler function
  2. // as external and receiving a delegate.
  3. [DllImport("Kernel32")]
  4. public static extern bool SetConsoleCtrlHandler(HandlerRoutine Handler, bool Add);
  5.  
  6. // A delegate type to be used as the handler routine
  7. // for SetConsoleCtrlHandler.
  8. public delegate bool HandlerRoutine(CtrlTypes CtrlType);
  9.  
  10. // An enumerated type for the control messages
  11. // sent to the handler routine.
  12. public enum CtrlTypes
  13. {
  14. CTRL_C_EVENT = 0,
  15. CTRL_BREAK_EVENT,
  16. CTRL_CLOSE_EVENT,
  17. CTRL_LOGOFF_EVENT = 5,
  18. CTRL_SHUTDOWN_EVENT
  19. }
  20.  
  21. private static bool ConsoleCtrlCheck(CtrlTypes ctrlType)
  22. {
  23. //TVOJ KOD KOJI TREBA DA SE DESI KAD SE UGASI KONZOLA
  24. Environment.Exit(0);
  25. return true;
  26. }
  27.  
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement