procedure TGetVersionInfoFromFile.readVersionFromFile;
var struSize : Dword;
dwBytes,someDummy : Dword;
a,txt : array[0..256] of char;
pAc: PansiChar; // my addition
p : pchar;
i : integer;
pp : pointer;
theFixedInfo : TVSFixedFileInfo;
theTrans : TTranslation;
s : string;
ts : TStringList;
begin
ts := TStringList.Create;
ts.add('CompanyName');
ts.add('FileDescription');
ts.add('FileVersion');
ts.add('InternalName');
ts.add('LegalCopyright');
ts.add('OriginalFilename');
ts.add('ProductName');
ts.add('ProductVersion');
strPCopy(a,FFileName);
strPCopy(pAc, FFileName); // my addition crash propgates from here
{ get size of data }
struSize := GetFileVersionInfoSize(a,someDummy);
if struSize=0 then exit;
p := NIL;
try
{ get memory }
GetMem(p,struSize+10);
{ get data }
GetFileVersionInfoA(pAc, 0, struSize,p); // now using the A version with ansii char variable.
{ get root info }
if not VerQueryValue(p,'\',pp,dwBytes) then exit;
move(pp^,theFixedInfo,dwBytes);
{ get translation info }
if not VerQueryValue(p,'\VarFileInfo\Translation',pp,dwBytes) then exit;
move(pp^,theTrans,dwBytes);
{ iterate over defined items }
for i:=0 to ts.count-1 do
begin
s := '\StringFileInfo\'+inttohex(theTrans.langID,4)+inttohex(theTrans.charset,4)+'\'+ts[i];
StrPCopy(a,s);
if not VerQueryValue(p,a,pp,dwBytes) then exit;
if dwBytes>0 then
begin
move(pp^,txt,dwBytes);
FmyVersionCategories.add(ts[i]);
FmyVersionStrings.add(StrPas(txt));
end;
end;
finally
{ release memory }
FreeMem(p);
end;
end;