0

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 Answers2

2

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
  • 131,367
  • 29
  • 160
  • 239
  • Thanks, but what about the IDispatch::GetTypeInfo and ::GetTypeInfoCount functions? Don't I have to return a valid ITypeInfo there? –  Aug 11 '09 at 00:08
  • Never mind. I see that GetTypeInfoCount can optionally just return 0. –  Aug 11 '09 at 00:14
1

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

taxilian
  • 14,229
  • 4
  • 34
  • 73