Author: Jonas Bilinkevicius
Is there a way to read the Language ID of a file first, and then use it to
construct the LocaleString?
Answer:
1 2 function GetFileTranslation(const Filename: string; FullName: Boolean = False):
3 string;
4 var5 VerInfSize, Sz: Cardinal;
6 LangID: Pointer;
7 VerInfo: Pointer;
8 Buf: array[0..255] of char;
9 begin10 Result := '';
11 if FileExists(Filename) then12 begin13 VerInfSize := GetFileVersionInfoSize(PCHAR(Filename), Sz);
14 if VerInfSize > 0 then15 begin16 VerInfo := AllocMem(VerInfSize);
17 try18 GetFileVersionInfo(PCHAR(Filename), 0, VerInfSize, VerInfo);
19 VerQueryValue(VerInfo, '\VarFileInfo\Translation', LangID, Sz);
20 if LangID < > nilthen21 case Ord(FullName) of22 0:
23 Result := IntToHex(MakeLong(HiWord(Longint(LangID^)),
24 LoWord(Longint(LangID^))), 8);
25 1:
26 if VerLanguageName(DWORD(LangID^), Buf, SizeOf(Buf)) > 0 then27 Result := Buf;
28 end;
29 finally30 FreeMem(VerInfo);
31 end;
32 end;
33 end;
34 end;
Pass False as the second parameter to construct this string. Pass True to get the language name.