WriteFile要求一个PChar类型的参数,如下调用
WriteFile(CommHandle, pBuffer, dwBlockSize, dwTotalBytesSent, nil)
定义一个数组:szTxBuf :array[0.. RX_BUFFER_SIZE] of Byte;
如何传递该数组到pBuffer。

解决方案 »

  1.   

    WriteFile(CommHandle, @pBuffer[0], dwBlockSize, dwTotalBytesSent, nil)
      

  2.   

    WriteFile(CommHandle, @pBuffer[0], dwBlockSize, dwTotalBytesSent, nil)
    结果写入的是szTxBuf 的地址, 而非数据值即, 如何得到一个数组其数据区域的指针
      

  3.   


    function WriteFile(hFile: THandle; const Buffer; nNumberOfBytesToWrite: DWORD;
      var lpNumberOfBytesWritten: DWORD; lpOverlapped: POverlapped): BOOL; stdcall;
      

  4.   

    在DELPHI里此函数声明如上,并不是你所给的参数使用方法如下:
    WriteFile(CommHandle, pBuffer[0], dwBlockSize, dwTotalBytesSent, nil);
    应该是不用指针去传缓冲区
      

  5.   

    对于你的例子按下面的调用你看看对不对
    WriteFile(CommHandle, szTxBuf[0], dwBlockSize, dwTotalBytesSent, nil);