不能直接用edit1.text:=buf
你得自己弄个程序把buf的内容转成二进制格式的字符串。

解决方案 »

  1.   

    function _strtohex(const s:string):string;
    var
      iCount:integer;
      Value,CH,CL:Byte;
    begin
      SetLength(Result,2 * Length(s));
      for iCount := 1 to Length(s) do
      begin
        Value := Byte(S[iCount]);
        CH:=(Value shr 4) and $0F;
        CL:=Value and $0F;
        if CL < $0A then CL := CL + $30 else CL := CL + $37;
        if CH < $0A then CH := CH + $30 else CH := CH + $37;
        Result[iCount * 2 - 1]:= Char(CH);
        Result[iCount * 2] := Char(CL);
      end;
    end;//范例 var
      s:string;
     begin
       s := 'ABCD'+#01#32;
       s := _strtohex(s);
       showMessage(s);
      //Result ='414243440120'
     end;