如何将OleVariant转换为IDispatch派生? [英] How to cast OleVariant to IDispatch derived?

查看:213
本文介绍了如何将OleVariant转换为IDispatch派生?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天带来另一个令我头疼的问题,



我将DAO 3.6类型库导入到我的delphi 7中,我开始看到很多有趣的内容所以我面对一个有趣的问题。



每当类Fields出现在另一个类的属性上时,它们都有正确的定义,我的意思是他定义为Fields,但是在索引类中,在他描述他结构的所有领域参与者的部分中,属性字段不会显示为Fields,而是OleVariant。



查看TableDefs的区别,具有Fields属性并与Index定义进行比较:

  _TableDef = interface(_DAO)
...
属性字段:字段读取Get_Fields;
...
end;

_Index = interface(_DAO)
...
属性字段:OleVariant读取Get_Fields写入Set_Fields;
...
end;

问题是,是否有一种方法来转换出现像OleVariant类型的Fields将被转换字段接口类型?



我非常gratefull所有这一切都帮助我在StackOverflow

解决方案

如果我正确理解您的问题,您会问如何将变体转换为 IDispatch 。这样做:

  IDispatch(V)

在你的情况下,我认为你有另外一种类型, Fields IDispatch 。您可以这样握住:

  IDispatch(V)as Fields 


I bring today another question that is burning my head,

I do import a DAO 3.6 type library to my delphi 7, and I start to see many interesting intefaces so I face on intriguing question.

Every time the class Fields appears on property of another class, they have the right definition, I mean, he is defined as Fields, but in Index class, in the parts where he describes all fields participants of his structure, the property fields appears not as Fields, but as OleVariant.

Look at the diference from TableDefs, that have Fields property to and compare to Index definition:

_TableDef = interface(_DAO)
...
property Fields: Fields read Get_Fields;
...
end;

_Index = interface(_DAO)
...
property Fields: OleVariant read Get_Fields write Set_Fields;
...
end;

The question is, is there a way to cast that Fields that appears like OleVariant type to be casted on Fields interface type?

I´m very gratefull for all that every help me here in StackOverflow

解决方案

If I understand your question correctly, you are asking how to convert a variant to an IDispatch. Do that like this:

IDispatch(V)

In your case I think you have another type, Fields that derives from IDispatch. You can get hold of that like this:

IDispatch(V) as Fields

这篇关于如何将OleVariant转换为IDispatch派生?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆