views:

79

answers:

2

I want to create an IDispatch object that returns a value for every property. Ask it for "foo", it returns something. "bar" returns something. "faid1jhgi31jifj" as well.

Any pointers?

+2  A: 

You need to override the GetIDsForNames methods with an appropriate implementation that returns a valid DISPID for any input parameters. Then override the Invoke method to ensure to return the correct value based on the dispatch id.

1800 INFORMATION
Thanks, but what about the IDispatch::GetTypeInfo and ::GetTypeInfoCount functions? Don't I have to return a valid ITypeInfo there?
Never mind. I see that GetTypeInfoCount can optionally just return 0.
A: 

You should also look at IDispatchEx, which is designed to give more flexibility for dynamic interfaces.

Taxilian