Delphi 判断exe, dll等应用程序[x86/x64]

2019-11-01 17:49:56 浏览数 (2)

代码语言:javascript复制
function FileIS64( Filename:string ):Boolean;
var
  tsl:TStringStream;
  rStr:AnsiString;
begin
  Result := False;
  if not FileExists(Filename) then Exit;
  
  tsl := TStringStream.Create;
  try
    tsl.LoadFromFile(Filename);
    tsl.Position := 0;
  
    SetLength(rStr, tsl.Size * 2 );
    BinToHex(@tsl.Bytes[0], PAnsiChar(rStr), tsl.Size);
    Result := (Pos('5045000064', string(rStr)) > 1); 
  finally
    FreeAndNil(tsl);
  end;
end;

主是要转hex后, 判断数字.

hex

0 人点赞