It depends on architecture of your application.
Any COM method accepts only "known" parameters in its methods which are primitive datatypes, VARIANT-based or user defined interfaces. So if you want to invoke some method in its implementation it must be defined in some other interface. And your COM-interface method should pass with pointer to another interface, not method. Try to create .idl file and compile it with /TLBOUT parameter.
Lets see an example.
library IMParameterLib
{
importlib("stdole2.tlb");
[
odl,
uuid(33377793-AABB-CCCC-DDDD-F0000000000F),
version(1.0),
helpstring("Test method interface"),
dual,
nonextensible,
oleautomation
]
interface IMethodTest : IDispatch{
[id(0x00000009), helpstring("parameter function")]
HRESULT ExchangeData([in] BSTR data);
[id(0x00000010), helpstring("test function")]
HRESULT SetTaskData([in] LONG type,
[in] void (*ExchangeData)(BSTR Text)
);
};
}
After compilation in .tlb file we'll see
interface IMethodTest : IDispatch {
[id(0x00000009), helpstring("parameter function")]
HRESULT ExchangeData([in] BSTR data);
[id(0x60020001)]
void __MIDL_0011(BSTR Text);
[id(0x00000010), helpstring("test function")]
HRESULT SetTaskData(
[in] long type,
[in] IMethodTest* ExchangeData);
};
So what we got after compilation? The pointer to IMethodTest interface! Therefore compiller sets only "known" data type for it, not an anonymous function (even if it defined within interface), which appears as void __MIDL_0011(BSTR Text);
but if we'll do dome changes like
[
uuid(99933366-FFFF-EEEE-DDDD-EEEEEEEEEEEE),
version(1.0),
]
interface IMethodToInvoke : IDispatch{
[id(0x00000009), helpstring("parameter function")]
HRESULT ExchangeData([in] BSTR data);
};
[
]
interface IMethodTest : IDispatch{
[id(0x00000010), helpstring("test function")]
HRESULT SetTaskData([in] LONG type,
[in] IMethodToInvoke * method
);
};
After compilation we'll see what we expected in code above.
This is guaranteed by COM technology to provide stable and safe (in some cases) data exchange between applications.