?? win32modem.cs
字號:
namespace SerialPorts
{
using System;
using System.Runtime.InteropServices;
internal class Win32Modem
{
// Methods
internal Win32Modem()
{
this.signal = new MODSIGS();
}
internal bool Get(IntPtr handle)
{
if (!Win32Modem.GetCommModemStatus(handle, out this.status))
{
int num1 = Marshal.GetLastWin32Error();
this.fault = "GetCommModemStatus() Failed. System Returned Error Code: " + num1.ToString();
return false;
}
this.signal.CTS = (this.status & 0x10) != 0;
this.signal.DSR = (this.status & 0x20) != 0;
this.signal.RING = (this.status & 0x40) != 0;
this.signal.RLSD = (this.status & 0x80) != 0;
return true;
}
[DllImport("kernel32.dll")]
private static extern bool GetCommModemStatus(IntPtr hFile, out uint lpModemStat);
// Properties
internal bool CtsState
{
get
{
return this.signal.CTS;
}
}
internal bool DsrState
{
get
{
return this.signal.DSR;
}
}
internal string Fault
{
get
{
return this.fault;
}
}
internal bool RingState
{
get
{
return this.signal.RING;
}
}
internal bool RlsdState
{
get
{
return this.signal.RLSD;
}
}
internal uint Status
{
get
{
return this.status;
}
}
// Fields
private string fault;
internal const uint MS_CTS_ON = 0x10;
internal const uint MS_DSR_ON = 0x20;
internal const uint MS_RING_ON = 0x40;
internal const uint MS_RLSD_ON = 0x80;
private MODSIGS signal;
private uint status;
// Nested Types
[StructLayout(LayoutKind.Sequential)]
internal protected struct MODSIGS
{
internal bool CTS;
internal bool DSR;
internal bool RLSD;
internal bool RING;
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -