private bool SetTimeouts(IntPtr hComDevice) { if (((int) hComDevice) <= 0) { return false; } try { COMMTIMEOUTS lpCommTimeouts = new COMMTIMEOUTS { ReadIntervalTimeout = m_ReadIntervalTimeout, ReadTotalTimeoutMultiplier = m_ReadTotalTimeoutMultiplier, ReadTotalTimeoutConstant = m_ReadTotalTimeoutConstant, WriteTotalTimeoutMultiplier = m_WriteTotalTimeoutMultiplier, WriteTotalTimeoutConstant = m_WriteTotalTimeoutConstant }; if (NativeMethods.SetCommTimeouts(hComDevice, ref lpCommTimeouts) == 0) { return false; } return true; } catch { return false; } }
internal static extern int SetCommTimeouts(IntPtr hFile, ref COMMTIMEOUTS lpCommTimeouts);