Home > Back-end >  Get version info from EXE file crashing on Delphi 11 after applying November Patch
Get version info from EXE file crashing on Delphi 11 after applying November Patch

Time:12-03

I'm using the function below to get version info from the current EXE file.

Problem is, after applying Delphi 11's November Patch , the function started to crash the application.

My code is listed below. The line that crashes is this :

VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize);

And here is the error, after this the app closes. This same funcion worked without problems before the patch. Maybe a bugged update ?

enter image description here

  function TForm1.version : string;
  var
    VerInfoSize: DWord;
    VerInfo: Pointer;
    VerValueSize: DWord;
    VerValue: PVSFixedFileInfo;
    Dummy: DWord;
    sfilename: string;
  begin
    sfilename := paramstr(0);
    VerInfoSize := GetFileVersionInfoSize(pchar(sfilename), Dummy);
    GetMem(VerInfo, VerInfoSize);
    GetFileVersionInfo(pchar(sfilename), 0, VerInfoSize, VerInfo);
    VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize);
    with VerValue^ do
    begin
      Result := inttostr(dwFileVersionMS shr 16);
      Result := Result   '.'   inttostr(dwFileVersionMS and $FFFF);
      Result := Result   '.'   inttostr(dwFileVersionLS shr 16);
      Result := Result   '.'   inttostr(dwFileVersionLS and $FFFF);
    end;
    FreeMem(VerInfo, VerInfoSize);
  end;

CodePudding user response:

Actually the problem was the EXE file did not have any version info, and an exception was generated and i was not handling it.

The code on the answer below works :

GetFileVersionInfoSize And GetFileVersionInfo return nothing

  • Related