特定类型的文件头信息都不一样,用流来试试你的问题
var
FStream:TStream;
Buffer:Word;
FStream:=TFileStream.Create(FileName,fmOpenRead or fmShareDenyWrite);
FStream.ReadBuffer(Buffer,2);
FStream.Position:=0;
if Buffer=$4D42 then
begin
//BMP
end
else if Buffer=$D8FF then
begin
//JPEG
end
else if Buffer=$4947 then
begin
//GIF
end
else if Buffer=$050A then
begin
//PCX
end
else if Buffer=$5089 then
begin
//PNG
end
else if Buffer=$4238 then
begin
//PSD
end
else if Buffer=$A659 then
begin
//RAS
end
else if Buffer=$DA01 then
begin
//SGI
end
else if Buffer=$4949 then
begin
//TIFF
end
else