1

我想在 Free Pascal 项目中使用 ActiveX-Object,从文档中我知道一种方法被声明为

long Fetch(VARIANT* vValue)

其中 vVariant 将在调用后包含一个结果(整数或浮点值)。

LazActiveX“导入类型库”函数已将其转换为

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

我对 OleVariant 有点惊讶,因为应该只返回简单的数据类型。当使用 v: OleVariant 调用 Fetch(v) 时,我还会收到一个 EOleSysError(类型不匹配)。

谁能向我解释如何在 TLB 中正确声明此方法或如何访问数据?不幸的是,我没有 Fetch() 的来源,并且其中一些内容已包含在 NDA 中...

4

1 回答 1

3

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.

于 2013-12-08T09:25:20.063 回答