Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
1.6 KiB

  1. /*************************************************************************
  2. *
  3. * BREAK.C
  4. *
  5. * Control-C and Control-Break routines
  6. *
  7. * Copyright (c) 1995 Microsoft Corporation
  8. *
  9. * $Log: N:\NT\PRIVATE\NW4\NWSCRIPT\VCS\BREAK.C $
  10. *
  11. * Rev 1.2 10 Apr 1996 14:21:38 terryt
  12. * Hotfix for 21181hq
  13. *
  14. * Rev 1.2 12 Mar 1996 19:52:16 terryt
  15. * Relative NDS names and merge
  16. *
  17. * Rev 1.1 22 Dec 1995 14:23:38 terryt
  18. * Add Microsoft headers
  19. *
  20. * Rev 1.0 15 Nov 1995 18:06:28 terryt
  21. * Initial revision.
  22. *
  23. * Rev 1.0 15 May 1995 19:10:14 terryt
  24. * Initial revision.
  25. *
  26. *************************************************************************/
  27. #include <stdio.h>
  28. #include <direct.h>
  29. #include <time.h>
  30. #include <stdlib.h>
  31. #include <nt.h>
  32. #include <ntrtl.h>
  33. #include <nturtl.h>
  34. #include <windows.h>
  35. #include "nwscript.h"
  36. #include "ntnw.h"
  37. /*
  38. * Handler for console events
  39. */
  40. BOOL WINAPI
  41. Handler( DWORD CtrlType )
  42. {
  43. if ( CtrlType & ( CTRL_C_EVENT | CTRL_BREAK_EVENT ) )
  44. return TRUE; /* don't execute default handler */
  45. else
  46. return FALSE;
  47. }
  48. /*
  49. * NTBreakOn
  50. *
  51. * Routine Description:
  52. *
  53. * Allow Ctrl+C and Ctrl+Break during logon script
  54. *
  55. * Arguments:
  56. * none
  57. *
  58. * Return Value:
  59. * none
  60. */
  61. void NTBreakOn( void )
  62. {
  63. (void) SetConsoleCtrlHandler( &Handler, FALSE );
  64. }
  65. /*
  66. * NTBreakOff
  67. *
  68. * Routine Description:
  69. *
  70. * Prevent Ctrl+C and Ctrl+Break during logon script
  71. *
  72. * Arguments:
  73. * none
  74. *
  75. * Return Value:
  76. * none
  77. */
  78. void NTBreakOff( void )
  79. {
  80. (void) SetConsoleCtrlHandler( &Handler, TRUE );
  81. }