Use of VARIANT* parameter in ActiveX method in Free Pascal

337 views Asked by At

I would like to use an ActiveX-Object in a Free Pascal project, from the documentation I know that one method is declared as

long Fetch(VARIANT* vValue)

where vVariant will contain a result (integer or floating point value) after calling.

The LazActiveX "Import type library" function has converted this to

_SomeApi = dispinterface
  ['...']
  ...
  function Fetch(vValue: OleVariant):Integer;
  ...
end;

I was a bit surprised about OleVariant, because only simple data types should be returned. I also get an EOleSysError (Type mismatch) raised when calling Fetch(v) with v: OleVariant.

Could anyone explain to me how to declare this method in the TLB correctly or how to access the data? Unfortunately, I do not have the source of Fetch() and some of this stuff is covered by an NDA ...

1

There are 1 answers

0
David Heffernan On BEST ANSWER

The import process resulted in an erroneous declaration. It should be:

function Fetch(out vValue: OleVariant): Integer;

if the semanics are OUT, and

function Fetch(var vValue: OleVariant): Integer;

if the semanics are IN/OUT.

Of course, either of those will work, but you can use var or out to express intent to the caller.