procedure TPerformSocket.PerfromFindKW(kw, SocketID: string);   
var
  wl: string;
  SocketTo: TCustomWinSocket;
  wSend: widestring;
  temp: string;
  i: integer;
begin
  SocketTo := TCustomWinSocket.Create(StrToInt(SocketID));
  wl := 'Hello';        //要传输得内容
  wSend := wl;          //为了能传输中文
  SocketTo.SendBuf(wSend[1], Length(wl) * 2);
end;
//我想知道我共传输了多少字节得怎么弄?

解决方案 »

  1.   


    Length(wl) Length(wSend) * 2應該就是你要的啊!
    一個中文也就是占用兩個 char 而已, 你用string也沒問題啊
      

  2.   

    Length(wSend) * 2
    这个不是字符串的长度么,求多少字节也可以么?
      

  3.   

    应该是:Length(wl) * 2 吧
      

  4.   

    用String就行啦,它也能传输中文的。 
    SocketTo.SendBuf(wl, length(wl));
    length(wl)就是你传送的字节数
      

  5.   

    同意楼上的
    直接用length(wl)就行
      

  6.   

    我的客户端是用C#写的,所以只能用widestring,我用string传的是乱码呀
      

  7.   

    SocketTo.SendBuf返回值就是传过去多少字节。
      

  8.   

    function SendBuf(var Buf; Count: Integer): Integer;
      

  9.   

    SocketTo.SendBuf(wSend, length(wSend)*2);
    这样试试
      

  10.   

    还有你SocketTo.SendBuf(wSend[1], Length(wl) * 2);第二个参数改成sizeof(wl)