// Returns nonzero if a keystroke is waiting to be read; otherwise returns zero. extern "C" int __cdecl _kbhit() { __acrt_lock(__acrt_conio_lock); int result = 0; __try { result = _kbhit_nolock(); } __finally { __acrt_unlock(__acrt_conio_lock); } return result; }
int __cdecl _kbhit ( void ) { int retval; _mlock(_CONIO_LOCK); /* secure the console lock */ __TRY retval = _kbhit_nolock(); /* determine if a key is waiting */ __FINALLY _munlock(_CONIO_LOCK); /* release the console lock */ __END_TRY_FINALLY return retval; }