Mirror

How to retrieve version info of system DLL's (Views: 23)


Problem/Question/Abstract:

Is there a way to read the Language ID of a file first, and then use it to construct the LocaleString?

Answer:

function GetFileTranslation(const Filename: string; FullName: Boolean = False):
  string;
var
  VerInfSize, Sz: Cardinal;
  LangID: Pointer;
  VerInfo: Pointer;
  Buf: array[0..255] of char;
begin
  Result := '';
  if FileExists(Filename) then
  begin
    VerInfSize := GetFileVersionInfoSize(PCHAR(Filename), Sz);
    if VerInfSize > 0 then
    begin
      VerInfo := AllocMem(VerInfSize);
      try
        GetFileVersionInfo(PCHAR(Filename), 0, VerInfSize, VerInfo);
        VerQueryValue(VerInfo, '\VarFileInfo\Translation', LangID, Sz);
        if LangID < > nil then
          case Ord(FullName) of
            0:
              Result := IntToHex(MakeLong(HiWord(Longint(LangID^)),
                LoWord(Longint(LangID^))), 8);
            1:
              if VerLanguageName(DWORD(LangID^), Buf, SizeOf(Buf)) > 0 then
                Result := Buf;
          end;
      finally
        FreeMem(VerInfo);
      end;
    end;
  end;
end;

Pass False as the second parameter to construct this string. Pass True to get the language name.

<< Back to main page