Interface types follow the same
rules as class types in variable and value typecasts. Class-type expressions
can be cast to interface types. For example, IMyInterface(SomeObject) provided
the class implements the interface.
An interface-type expression can
be cast to Variant. If the interface is of type IDispatch or a
descendant, the resulting variant has the type code varDispatch.
Otherwise, the resulting variant has the type code varUnknown.
A variant whose type code is varEmpty,
varUnknown, or varDispatch can be cast to IInterface. A
variant whose type code is varEmpty or varDispatch can be cast to
IDispatch.
在变量和指的类型转换中,接口类型遵循与类类型相同的规则。类类型表达式可以被转换到接口类型。例如,IMyInterface(SomeObject)提供了实现接口的类。
接口类型的表达式可以被转换为Variant类型。如果接口类型是IDispatch或其后裔,那么转换得到的变体其类型代码为varDispatch,否则为varUnknown。
类型代码为varEmpty、varUnknown或varDispatch的变体可以被转换为IInterface。类型代码为varEmpty或varDispatch的变体可以被转换为IDispatch。