大神们好  能问个问题吗
Src:array [0..11] of Byte;
Src里存了12个数字
怎么把Src里的数字一个个转换成二进制赋值给一个个的string吗
string str0=src【0】的二进制
string str1=src【1】的二进制


解决方案 »

  1.   


    function ByteToBitStr(Value: Byte): String;
    var
      I: Byte;
    begin
      Result := '00000000';
      if Value <> 0 then
      begin
        for I := 8 downto 1 do
        begin
          if (Value and 1) = 1 then
            Result[I] := '1'
          else
            Result[I] := '0';
          Value := (Value shr 1);
        end;
      end;
    end;
      

  2.   


    var
      lStr: AnsiString;
      lBytes: Array[0..11] of Byte;
      lIndex, lSI: Integer;
    begin
      lBytes[3] := 66;
      lBytes[1] := 2;
      lBytes[9] := 89;
      SetLength(lStr, Length(lBytes) * 2);
      lSI := 1;
      for lIndex := Low(LBytes) to High(lBytes) do
      begin
        Move(AnsiString(IntToHex(lBytes[lIndex]))[1], lStr[lSI], 2);
        Inc(lSI, 2);
      end;  ShowMessage(lStr);
    end;