如果用的是MSComm32控件,有个InputLen属性

解决方案 »

  1.   

    >>如果用的是MSComm32控件,有个InputLen属性
    对不起,是InBufferCount
      

  2.   

    /// <summary>
    /// The ReadFile function reads data from a file, starting at the 
    /// position indicated by the file pointer. After the read operation 
    /// has been completed, the file pointer is adjusted by the number 
    /// of bytes actually read, unless the file handle is created with the 
    /// overlapped attribute. If the file handle is created for overlapped 
    /// input and output (I/O), the application must adjust the position of 
    /// the file pointer after the read operation. 
    /// This function is designed for both synchronous and asynchronous 
    /// operation. The ReadFileEx function is designed solely for asynchronous 
    /// operation. It lets an application perform other processing during a 
    /// file read operation.
    /// </summary>
    [DllImport("kernel32.dll", SetLastError=true)]
    private static extern Boolean ReadFile
    (
    IntPtr hFile, 
    [Out] Byte[] lpBuffer, 
    UInt32 nNumberOfBytesToRead,
    out UInt32 nNumberOfBytesRead, 
    IntPtr lpOverlapped
    );
      

  3.   

    各位大侠,我是用READFILE读串口,判断缓冲或串口时间时总有一个时间差,很难得到一个完整的数据处理,怎摸办?
      

  4.   

    各位大侠,我是用READFILE读串口,判断缓冲或串口事件时总有一个时间差,很难得到一个完整的数据处理,怎摸办?
      

  5.   

    http://www.codeproject.com/dotnet/DotNetComPorts.asp
      

  6.   

    我是用WaitCommEvent和SetCommMask进行判断的
      

  7.   

    ReadFile(hPort, buf, 1, out gotbytes, unmanagedOv)
    gotbytes有时会为0。