BUG: Windows 95 Access Violation Error After Disabling CTRL+C

Last reviewed: March 11, 1997
Article ID: Q137379
The information in this article applies to:

- Microsoft Win32 Application Programming Interface (API) included with:

   - Microsoft Windows 95

SYMPTOMS

In a Win32 environment, a console application can be terminated by pressing CTRL+C. To disable CTRL+C input, a console application can call the SetConsoleCtrlHandler(NULL, TRUE) API function.

When this API function is called in Windows NT, CTRL+C is ignored if pressed. However, when it is called in Windows 95, pressing CTRL+C generates an Access Violation error. Similarly, when this API is called in Windows 95, pressing CTRL+BREAK generates an Access Violation error.

RESOLUTION

There are two alternatives when you want to disable CTRL+C and avoid generating an Access Violation error:

  1. Install a console control handler to capture and ignore the CTRL+C keypress:

          SetConsoleCtrlHandler(MyHandler, TRUE);
          BOOL MyHandler(DWORD dwEventType)
          {
    
             if ( dwEvnetType == CTRL_C_EVENT
             if ( dwEventType == CTRL_C_EVENT )
                return TRUE;   // CTRL+C handle by function
             else
                return FALSE;  // pass to next handler
          }
    
       -or-
    
    

  2. Disable CTRL+C by disabling the ENABLE_PROCESSED_INPUT console mode. Disabling the ENABLE_PROCESSED_INPUT console mode then reports CTRL+C to the input buffer, not the system:

          SetConsoleMode( hConsoleHandle,
    
              (Mode & ~ ENABLE_PROCESSED_INPUT) );
    
    

STATUS

Microsoft has confirmed this to be a bug in the products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


Keywords : BseCon kbprg kbbuglist
Platform : WINDOWS
Issue type : kbbug


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 11, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.