取文件的前几个字节<br>Bmp : 42 4d<br>Jpg : FF D8<br>Gif : 47 49 46<br><br><br>procedure TForm1.Button1Click(Sender: TObject);<br>Var<br> s : String;<br> b : Array[0..2] Of Byte;<br> fs : TFileStream;<br>begin<br> If Not OpenDialog1.Execute Then Exit;<br> s := OpenDialog1.FileName;<br> fs := TFileStream.Create(s, fmOpenRead);<br> Try<br> fs.Read(b, 3);<br> Edit1.Text := IntToHex(b[0], 2) + ' ' + IntToHex(b[1], 2) + ' ' + IntToHex(b[2], 2);<br> Finally<br> FreeAndNil(fs);<br> End;<br>end;