Procedure aa(const Source: Array of Byte; var Dest: Array of Byte; Idx, count : Integer);
var
    S, D: PChar;
    II : Integer ;
begin
    S := PChar(@ResArray);
    D := PChar(@DesArray);
    for II := 0 to CCount -1 do
    begin
        D[II] :=  S[BIdx + II]
    end;
end;Procedure bb(const Source: Array of Byte; var Dest: Array of Byte; Idx, count : Integer);
var
  S, D: PByte;
  I: Integer;
begin
  S := PByte(@Source);
  D := PByte(@Dest);
 for I := 0 to count-1 do
      D[I+Idx] := S[I];
end;
在使用Pbyte的时候要求类型,编译不通过,Pchar可以编译通过,这是为什么啊......

解决方案 »

  1.   

    因为PByte是指向一个Byte类型的指针,只占一个字节
    PChar是可以看做是字符串数组
      

  2.   

    byte和pchar风马牛不相及下边的可以运行
    Procedure bb(const Source: Array of Byte; var Dest: Array of Byte; Idx, count : Integer);
    var
      S, D: PByte;
      I: Integer;
    begin
      S := PByte(@Source);
      D := PByte(@Dest);
     for I := 0 to count-1 do
          D[I+Idx] := S[I];
    end;procedure TForm15.btn1Click(Sender: TObject);
    var
      dest : array[0..2] of Byte;
    begin
      dest[0] := 4;
      dest[1] := 5;
      dest[2] := 6;
      bb([1, 2, 3], dest, 0, 3);   //返回 dest{1, 2, 3}end;
      

  3.   


    编译不通过啊,
    [Error] Unit1.pas(35): Array type required
      

  4.   

      如果你一定要使用PByte你就这样写吧! var
      S, D: PByte;
      I: Integer;
    begin
      S := PByte(@Source);
      D := PByte(@Dest);
     for I := 0 to count-1 do
          PByte(integer(D)+ I + Idx)^ := PByte(integer(S) + I)^;
    end;
      

  5.   


    或者下面的代码也可以!
    var
      S, D: PByteArray;
      I: Integer;
    begin
      S := PByteArray(@Source);
      D := PByteArray(@Dest);
     for I := 0 to count-1 do
          D[I + Idx] := S[I];
    end;
      

  6.   

    delphi版本问题.-------------------------------------------------
    你要么使用数组指针, 要么就数组, 两个来回绕弯是给你自己使绊子你的功能可以简化成这样
    Procedure bb(const Source: Array of Byte; var Dest: Array of Byte; Idx, count : Integer);
    var
      I: Integer;
    begin
      for I := 0 to count-1 do
        Dest[I+Idx] := Source[I];
    end;
      

  7.   

    PChar和PByte的区别到底是什么?
      

  8.   

    PChar 是一个指向零终止字符串的指针;
    而PByte  = ^Byte; 那么PByte就是指向Byte的指针,范围就是0..255的数值了