如何把Byte数组转换成整数?? 最后结果为 296591Procedure TForm1.Button4Click(Sender: TObject);
var
  MyArray_byte : Array [0..3] Of Byte;Begin
  MyArray_byte[0]:=143;   //8F
  MyArray_byte[1]:=134;   //86
  MyArray_byte[2]:=4;     //4
  MyArray_byte[3]:=0;     //0  //如何把数组转换成整数   296591
End;

解决方案 »

  1.   

    tmpInt := PInteger(@MyArray_byte[0])^;
      

  2.   


    var
      MyArray_byte : Array [0..3] Of Byte;
      i:Integer;
    Begin
      MyArray_byte[0]:=143; //8F
      MyArray_byte[1]:=134; //86
      MyArray_byte[2]:=4; //4
      MyArray_byte[3]:=0; //0
      Move(MyArray_byte[0],i,SizeOf(Integer));
      ShowMessage(IntToStr(i));
      //如何把数组转换成整数 296591
    End;
      

  3.   

    var
      MyArray_byte : Array [0..3] Of Byte;
      Value: Integer;
    begin
      MyArray_byte[0]:=143; //8F
      MyArray_byte[1]:=134; //86
      MyArray_byte[2]:=4; //4
      MyArray_byte[3]:=0; //0
      asm
        mov edx, [MyArray_byte]
        mov Value, edx
      end;
      ShowMessage(IntToStr(Value));
    end;
      

  4.   

    Move函数就免了吧,不知道怎么想的
      

  5.   

    顶,还可以:
    tmpInt := MyArray_byte[3] shl 24 + MyArray_byte[2] shl 16 + MyArray_byte[1] shl 8 + MyArray_byte[0];