var
InfoSize , Zero : DWORD;
VersionInfo ,Info : Pointer;
Translation: PLANGANDCODEPAGE;
InfoPath : String;
begin
InfoSize := GetFileVersionInfoSize(PChar(NamePath),Zero);
if InfoSize = 0 then begin
Exit;
end;
GetMem(VersionInfo,InfoSize);
try
if Not GetFileVersionInfo(PChar(NamePath),0,InfoSize,VersionInfo) then begin
Exit;
end;
if VerQueryValue(VersionInfo, '\VarFileInfo\Translation ', Pointer(Translation), InfoSize) then
begin
InfoPath := '\StringFileInfo\ ' + inttoHex(Translation^.wLanguage, 4) + inttoHex(Translation^.wCodePage, 4) + '\ ';
GetMem(Info, 2000);
VerLanguageName(Translation^.wLanguage, Info, 2000);
end
else begin//set default value
InfoPath := '\StringFileInfo\040904E4\ ';
end;
if VerQueryValue(VersionInfo, PChar(InfoPath + 'ProductVersion '), Info, InfoSize) then
S1 := string(PChar(Info)); //版本;
if VerQueryValue(VersionInfo, PChar(InfoPath + 'CompanyName '), Info, InfoSize) then
S2 := string(PChar(Info)); //厂商;
if VerQueryValue(VersionInfo, PChar(InfoPath + 'LegalTrademarks '), Info, InfoSize) then
S3 := string(PChar(Info)); //
if VerQueryValue(VersionInfo, PChar(InfoPath + 'FileDescription '), Info, InfoSize) then
S4 := string(PChar(Info)); //描述;