12-12 Chapter 12: Cash Drawer Interface
// Lock Mutex when accessing shared memory
WaitForSingleObject( g_hSharedMemoryMutex, INFINITE );
g_hHWPortMutex = CreateMutex( &m_Attributes, FALSE, (LPCTSTR) sData );
if ( g_hHWPortMutex != NULL )
{
m_pDC->DCPrintf(
DCM_APIHIGH,
_T(" ..create m_hPowerMutex") );
// Create a security attribute allowing global access
GetGlobalSA( _T("mutex"), _T("NCRPowerSharingMutex"), &m_Attributes,
&m_SD );
// create named mutex that prevents the cash drawer from firing
// when the printer is printing
// "NCRPowerSharingMutex"
m_hPowerMutex = CreateMutex( &m_Attributes, FALSE,
_T("NCRPowerSharingMutex") );
} // HWPortMutex created
}
ReleaseMutex( g_hSharedMemoryMutex ); // TAR 95236
} // OS is WIN95 or WINNT and NCRKPDev driver present
return RetStatus;
}
///////////////////////////////////////////////////////////////
void Terminate()
{
if ( m_bInitialized )
{
// Lock Mutex when accessing shared memory
WaitForSingleObject( g_hSharedMemoryMutex, INFINITE );
CloseHandle( m_hPowerMutex );
CloseHandle( g_hHWPortMutex ); // TAR 95236
// if the NT port driver was opened...
if (m_bPortDrvr )
{