Chapter 12: Cash Drawer Interface 12-11
{
// -rtf- Create a security attribute allowing global access
GetGlobalSA( _T("CreateFile"), _T("NCRKPDev"), &m_Attributes, &m_SD
);
g_hPortDrvr = CreateFile(
"\\\\.\\NCRKPDev", // Open the Device "file"
GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
(LPSECURITY_ATTRIBUTES) &m_Attributes, // no security
OPEN_EXISTING,
0, // flags
NULL);
if (g_hPortDrvr == INVALID_HANDLE_VALUE) // Was the device opened?
{
DWORD hr = GetLastError();
m_bPortDrvr = FALSE;
InitError = TRUE;
}
else
{
m_bPortDrvr = TRUE;
}
} // end if (g_hPortDrvr==0)
ReleaseMutex( g_hSharedMemoryMutex );
} // WINNT OS
else
{
m_nOSVersion = OS_WINDOWS_95;
}
} // end if (!InitError)
// if the (OS is WINNT AND the port driver was opened )
if ( !InitError )
{
// Create a security attribute allowing global access
GetGlobalSA( _T("mutex"), sData, &m_Attributes, &m_SD );