An interface pointer variable is a reference to a COM object. You use it when calling COM object functions. Declaration syntax:
Here Interface is either interface name or coclass name. ip is variable name. If you use interface name, the variable has Interface type. If you use coclass name, the type of the variable is the type of the default interface of the coclass.
Usually, coclasses and interfaces are declared in type libraries. You should use type library name too, like in this example:
When you assign one interface pointer variable to another (for example, using operator =), it does not copy the object, but just increments its reference count. Both variables will refer to the same object. That is fast. QM may generate error on interface pointer type mismatch in an assignment operation. Use operator + to compile without error. If that interface is not supported, error will be generated at run time.
Interface1 a._create Interface2 b=+a
To explicitly delete the object, assign 0 to the interface pointer variable. It decrements object's reference count. It is not necessary because QM does it implicitly when the variable goes out of scope. You should not call AddRef or Release, because QM manages this automatically.
COM objects usually cannot be used by multiple threads, and therefore interface pointer variables should be declared with local or thread scope.
An interface pointer variable itself is not an object. It is just pointer to the object, and double pointer to the interface. Like any other pointer, it is 4-byte integer.