12-24 Chapter 12: Cash Drawer Interface
{
DWORD hr = GetLastError();
result = FALSE;
}
} //m_bPortDrvr
} //NT
ReleaseMutex( g_hHWPortMutex ); // TAR 95236
return result;
}
//////////////////////////////////////////////////////////////////////////////
// CDevice7402::ReadIOPort
// We use the port addresses obtained from QueryConf().
BOOL ReadIOPort( DWORD *databytes, WORD ioport )
{
BOOL result = TRUE;
DWORD FileOffset=0x40;
DWORD DataRead;
WaitForSingleObject( g_hHWPortMutex, INFINITE );
if ((m_nOSVersion == OS_WINDOWS_95) || (m_nOSVersion == OS_WINDOWS_CE))
{ // WIN 95 I/O write
*databytes = _inpd( ioport ); //Read 32-bits from ioport
} //Win95
else
{ // WIN NT I/O read
if (m_bPortDrvr == TRUE) // if Wedge NT driver opened successfully
{
SetFilePointer( g_hPortDrvr, ioport, (PLONG)&FileOffset, FILE_BEGIN);
if ( ReadFile(
g_hPortDrvr, // Handle to device
(LPSTR) databytes, // address of data buffer
(DWORD) 4, // Length of buffer in bytes
&DataRead, // bytes read
NULL ) == FALSE ) // NULL means wait till I/O completes.
{
DWORD hr = GetLastError();
result = FALSE;
}
} // m_bPortDrvr
} // NT