IUnknown

IUnknown - is the base class for all OLE/COM/ActiveX components


VBA use the CreateTypeLib2 API function to generate the type library when they build their own COM components.
VBA can define a parameter as being of type IUnknown by using a reference to the external library stdole2.tlb and a ITypeInfo to describe the data type.
Programmers are not allowed to use an IUnknown data type from VBA
This is a hidden data type


IUnknown myUnknown; 

The Object data types is the core connection between VBA and COM
The Object type however does not expose the three methods of the actual IUnknown interface


Methods

AddRef - This method is called when the set operator is invoked and increments the target object's reference count
Release - This method is called when the object is explicitley set to Nothing and decrements the target object's reference count
QueryInterface - This method is used when resolving a late binding member resolution



The only difference between using IUnknown and Idispatch is that the type librray is required to use an IUnknown - derived interface
You cannot use IUnknown for scripting languages



© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext