public static Commprop GetComPortProperties(string portName) { var commProp = new Commprop(); IntPtr hFile = CreateFile(@"\\.\" + portName, 0, 0, IntPtr.Zero, 3, 0x80, IntPtr.Zero); GetCommProperties(hFile, ref commProp); CloseHandle(hFile); return(commProp); }
static extern bool GetCommProperties(IntPtr hFile, ref Commprop lpCommProp);