请问定义为 aa= interface(IDispatch)这样的接口如何调用其中的过程与函数

andywan 2005-08-05 04:01:04
请问定义为 aa= interface(IDispatch) 

function b: OleVariant; safecall;
procedure c(P1: OleVariant); safecall;

end;


这样的接口如何调用其中的过程与函数?
...全文
218 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
andywan 2005-09-04
  • 打赏
  • 举报
回复
问题没解决 ,先结贴,,以后再说
LocustWei 2005-08-13
  • 打赏
  • 举报
回复
TClass = Class(TAutoObject, aa)
protected
function b: OleVariant; safecall;
procedure c(P1: OleVariant); safecall;
end;
andywan 2005-08-12
  • 打赏
  • 举报
回复
Interfaces, like classes....


有没有实际的代码可参考的?太忙没有时间查资料,希望有知道的能贴一下,谢谢了,也谢谢楼上各位!
MartinWang 2005-08-09
  • 打赏
  • 举报
回复
a class cannot implement a dispatch interface.
chenxuqian 2005-08-09
  • 打赏
  • 举报
回复
kongguangming 2005-08-09
  • 打赏
  • 举报
回复
Interfaces, like classes, can be declared only in the outermost scope of a program or unit, not in a procedure or function declaration. An interface type declaration has the form

type interfaceName = interface (ancestorInterface)

['{GUID}']
memberList
end;

where (ancestorInterface) and ['{GUID}'] are optional. In most respects, interface declarations resemble class declarations, but the following restrictions apply.

The memberList can include only methods and properties. Fields are not allowed in interfaces.
Since an interface has no fields, property read and write specifiers must be methods.
All members of an interface are public. Visibility specifiers and storage specifiers are not allowed. (But an array property can be declared as default.)
Interfaces have no constructors or destructors. They cannot be instantiated, except through classes that implement their methods.

Methods cannot be declared as virtual, dynamic, abstract, or override. Since interfaces do not implement their own methods, these designations have no meaning.

Here is an example of an interface declaration:

type

IMalloc = interface(IInterface)
['{00000002-0000-0000-C000-000000000046}']
function Alloc(Size: Integer): Pointer; stdcall;
function Realloc(P: Pointer; Size: Integer): Pointer; stdcall;
procedure Free(P: Pointer); stdcall;
function GetSize(P: Pointer): Integer; stdcall;
function DidAlloc(P: Pointer): Integer; stdcall;
procedure HeapMinimize; stdcall;

end;

In some interface declarations, the interface reserved word is replaced by dispinterface. This construction (along with the dispid, readonly, and writeonly directives) is platform-specific and is not used in Linux programming.
andywan 2005-08-09
  • 打赏
  • 举报
回复
谢谢,请问如何实现这个类,假如有GUID的情况?
dejoy 2005-08-07
  • 打赏
  • 举报
回复
由于接口没有和类一样的类引用功能,不能从一个接口变量得到此接口变量的类型(GUID),也不能得到实现此接口的类的实例。
linzhengqun 2005-08-05
  • 打赏
  • 举报
回复
这是COM自动接口啊,用Delphi的向导帮你生成吧。

从原理上来说,你要写一个实现该接口的类,才能调用

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧