The following is the Interface Definition Language (IDL) definition for the IEnumVARIANT interface as seen in the stdole typelib.
[
uuid(00020404-0000-0000-C000-000000000046),
hidden
]
interface IEnumVARIANT : IUnknown
{
HRESULT Next([in] unsigned long celt, [in] VARIANT* rgvar, [out] unsigned long* pceltFetched);
HRESULT Skip([in] unsigned long celt);
HRESULT Reset();
HRESULT Clone([out] IEnumVARIANT** ppenum);
};
For an interface to be implementable in VB it cannot contain any 'out only' parameters ([out]). For this reason, if you try to implement this interface declared in this manner in a VB class using 'Implements', you get and error ("Not a valid interface for Implements"). To rectify this situation, we need to create a new typelib to override this declaration with one that VB will let us implement. The IDL for the redefinition looks like this:
[
uuid(00020404-0000-0000-C000-000000000046),
hidden
]
interface
IEnumVARIANT : IUnknown
{
HRESULT
Next([in] LONG cElements, [in, out]
VARIANT* aVariants, [in] LONG
lpcElementsFetched);
HRESULT Skip([in] LONG cElements);
HRESULT Reset();
HRESULT Clone([in, out] IEnumVARIANT** lppIEnum);
};
Notice that all we had to do is replace each occurrence of [out] with [in, out] and we now have an interface that is implementable in VB.
Here are some good IDL references you can use to learn more about COM and writing your own type libraries.
"COM IDL & Interface Design" by Dr. Al Major Wrox Press