How to distinguish OleVariant from IDispatch?

I bring another question today that burns my head,

I am importing DAO 3.6 type library into my delphi 7 and I am starting to see many interesting queries, so I am faced with an intriguing question.

Every time the Fields class appears in a property of another class, it has the correct definition, I mean that it is defined as fields, but in the Index class, in those parts where it describes all the fields of the members of its structure, the field property does not appear as fields, but as OleVariant.

Take a look at the differences between TableDefs that have a Fields property and compare to the 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 specify that fields that look like OleVariant are cast from the Fields interface type?

I am very grateful for everything that helps me on StackOverflow

+1


source to share


1 answer


If I understand your question correctly, you are asking how to convert a variant to IDispatch

. Do it like this:

IDispatch(V)

      



In your case, I think you have a different type Fields

, which comes from IDispatch

. You can figure it out:

IDispatch(V) as Fields

      

+4


source







All Articles