Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6082153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:15:26+00:00 2026-05-23T11:15:26+00:00

DelphiXe. For reception of the version of a file I use function: function FileVersion(AFileName:

  • 0

DelphiXe.

For reception of the version of a file I use function:

function FileVersion(AFileName: string): string;
var
  szName: array[0..255] of Char;
  P: Pointer;
  Value: Pointer;
  Len: UINT;
  GetTranslationString: string;
  FFileName: PChar;
  FValid: boolean;
  FSize: DWORD;
  FHandle: DWORD;
  FBuffer: PChar;
begin
  try
    FFileName := StrPCopy(StrAlloc(Length(AFileName) + 1), AFileName);
    FValid := False;
    FSize := GetFileVersionInfoSize(FFileName, FHandle);
    if FSize > 0 then
    try
      GetMem(FBuffer, FSize);
      FValid := GetFileVersionInfo(FFileName, FHandle, FSize, FBuffer);
    except
      FValid := False;
      raise;
    end;
    Result := '';
    if FValid then
      VerQueryValue(FBuffer, '\VarFileInfo\Translation', p, Len)
    else
      p := nil;
    if P <> nil then
      GetTranslationString := IntToHex(MakeLong(HiWord(Longint(P^)),
        LoWord(Longint(P^))), 8);
    if FValid then
    begin
      StrPCopy(szName, '\StringFileInfo\' + GetTranslationString +
        '\FileVersion');
      if VerQueryValue(FBuffer, szName, Value, Len) then
        Result := StrPas(PChar(Value));
    end;
  finally
    try
      if FBuffer <> nil then
        FreeMem(FBuffer, FSize);
    except
    end;
    try
      StrDispose(FFileName);
    except
    end;
  end;
end;

For the majority of executed files and libraries it returns correct value. But at some files the version is cut off and shown without Build.
Here for example file BASS.DLL (http://us.un4seen.com/files/bass24.zip)
In Windows Explorer in properties of a file I see version 2.4.7.1, function result=’2.4.7′ 🙁

I open a file through Resourcehacker.exe (http://angusj.com/resourcehacker/), I look structure VersionInfo:

1 VERSIONINFO
FILEVERSION 2,4,7,1
PRODUCTVERSION 2,4,0,0
FILEOS 0x4
FILETYPE 0x2
{
BLOCK "StringFileInfo"
{
    BLOCK "000004b0"
    {
        VALUE "CompanyName", "Un4seen Developments"
        VALUE "FileDescription", "BASS"
        VALUE "FileVersion", "2.4.7"
        VALUE "LegalCopyright", "Copyright © 1999-2010"
    }
}

BLOCK "VarFileInfo"
{
    VALUE "Translation", 0x0000 0x04B0
}
}

Question: how to receive 2.4.7.1, i.e. the full version?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:15:27+00:00Added an answer on May 23, 2026 at 11:15 am

    If you want the file version of the root block, then forget about the language specific translation:

    function FileVersion(const FileName: TFileName): String;
    var
      VerInfoSize: Cardinal;
      VerValueSize: Cardinal;
      Dummy: Cardinal;
      PVerInfo: Pointer;
      PVerValue: PVSFixedFileInfo;
    begin
      Result := '';
      VerInfoSize := GetFileVersionInfoSize(PChar(FileName), Dummy);
      GetMem(PVerInfo, VerInfoSize);
      try
        if GetFileVersionInfo(PChar(FileName), 0, VerInfoSize, PVerInfo) then
          if VerQueryValue(PVerInfo, '\', Pointer(PVerValue), VerValueSize) then
            with PVerValue^ do
              Result := Format('v%d.%d.%d build %d', [
                HiWord(dwFileVersionMS), //Major
                LoWord(dwFileVersionMS), //Minor
                HiWord(dwFileVersionLS), //Release
                LoWord(dwFileVersionLS)]); //Build
      finally
        FreeMem(PVerInfo, VerInfoSize);
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

DelphiXe; Xp,Vista,Win7,WSrv2008R2; 0.DEP(Data Execution Prevention) CPU supported Function isCpuDEP:bool; begin Result:=... //??? end; 1.How
Using DelphiXE, I'm trying to show the length of a wav file on a
I need a version of PBears thtmlviewer that will work in DelphiXE. I found
I'm trying to access an update.txt file on my website, using a DelphiXE compiled
I need to use a Delphi component to encrypt a file that can then
ShlObj.pas line 9922 (as in Delphi XE): type BFFCALLBACK = function(Wnd: HWND; uMsg: UINT;
I would like to use RTTI to examine the types contained within project source
The following code used to compile with Delphi 2007: constructor TMyFile.Create(const _Filename: string); begin
Win7x64, DelphiXe. Has written the program, which registers the control panel applet (as here
Has anyone run into issues serializing components into a file and reading them back,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.