BUG: Windows 95 Access Violation Error After Disabling CTRL+CID: Q137379
|
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.
There are two alternatives when you want to disable CTRL+C and avoid generating an Access Violation error:
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-
SetConsoleMode( hConsoleHandle,
(Mode & ~ ENABLE_PROCESSED_INPUT) );
Microsoft has confirmed this to be a bug in the products listed at the beginning of this article.
Additional query words:
Keywords : kbprg kbConsole kbKernBase kbGrpKernBase
Version : winnt:
Platform : winnt
Issue type : kbbug
Last Reviewed: July 20, 1999