Forum > General

Error: Illegal qualifier in converting Delphi unit

(1/1)

vfclists:
Hi guys,

I am trying to compile the TVersionInfo component by Anders Melander
at http://melander.dk/articles/versioninfo/.

It defines the structure below

type
 TTranslationRec = packed record
   case Integer of
   0: (
     LanguageID: WORD;
     CharsetID: WORD);
   1: (
     TranslationID: DWORD);
 end;
 PTranslationRec = ^TTranslationRec;
 TTranslationTable = array[0..0] of TTranslationRec;
 PTranslationTable = ^TTranslationTable;


which causes the compiler error

VersionInfo.pas(141,37) Error: Illegal qualifier

function TVersionInfo.GetCharset(Index: integer): WORD;
begin
 Result := TranslationTable[Index].CharsetID;
end;

Is there a way to convert for Free Pascal compatibility?

Ñuño_Martínez:
What is the type of TranslationTable?

Zoran:
The variable TranslationTable seems not to be declared.

Somwhere in code the variable has to be declared:

--- Code: ---var
  TranslationTable: TTranslationTable;

--- End code ---
Then, this array has to be initialized somewhere.

Or it's a constant, which also must be declared and initialized:

--- Code: ---const
  TranslationTable: TTranslationTable = [ , , , ...]; // <- some actual list of values

--- End code ---

mas steindorff:
this code works for me

--- Code: ---...
Implementation
  Uses    windows   ;

function TFMainform.myGetVersion(filename:string=''): String;
var
  my :record
    Dummy: DWord;
    VerInfo: Pointer;
    VerInfoSize: DWord;
    VerValueSize: DWord;
    VerValue:  PVSFixedFileInfo;
    end;
begin
  Result:='';
  my.Dummy:=0; // to keep the compiler happy
  if filename='' then filename:=ParamStr(0);
  my.VerInfoSize := GetFileVersionInfoSize(PChar(filename), my.Dummy);
  if my.VerInfoSize=0 then
     exit;
  GetMem(my.VerInfo, my.VerInfoSize);
  GetFileVersionInfo(PChar(filename), 0, my.VerInfoSize, my.VerInfo);
  VerQueryValue(my.VerInfo, '\', Pointer(my.VerValue), my.VerValueSize);
  with my.VerValue^ do  begin
     result := IntTostr(dwFileVersionMS shr 16);
     result := result+'.'+   IntTostr(dwFileVersionMS and $FFFF);
     result := result+'.'+   IntTostr(dwFileVersionLS shr 16);
     result := result+'.'+   IntTostr(dwFileVersionLS and $FFFF);
  end;
  FreeMem(my.VerInfo, my.VerInfoSize);
end;
{ TFMainform }

Procedure TFMainform.FormCreate(Sender: TObject);

Begin
   RevStr := 'Rev:' + myGetVersion('');
end;

--- End code ---

Navigation

[0] Message Index

Go to full version