资源说明:CSerial::EPort CSerial::CheckPort (LPCTSTR lpszDevice)
{
// Try to open the device
HANDLE hFile = ::CreateFile(lpszDevice,
GENERIC_READ|GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
0,
0);
// Check if we could open the device
if (hFile == INVALID_HANDLE_VALUE)
{
// Display error
switch (::GetLastError())
{
case ERROR_FILE_NOT_FOUND:
// The specified COM-port does not exist
return EPortNotAvailable;
case ERROR_ACCESS_DENIED:
// The specified COM-port is in use
return EPortInUse;
default:
// Something else is wrong
return EPortUnknownError;
}
}
// Close handle
::CloseHandle(hFile);
// Port is available
return EPortAvailable;
}
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。
English
