Pregunta

I have a DLL that provides functions with a variable parameter list that are defined like

my_func(int var,...)

Depending on how my_func() is called it expectes more or less additional parameters.

Now this DLL has to be wrapped by an MFC-based ActiveX-control. For the method definitions I can find many VT_ and VTS_ defines that wrap to a specific, pre-defined type. But is it possible to have a ActiveX-method with such a variable parameter list too?

If yes: how can it be implemented?

¿Fue útil?

Solución

Although it is technically possible, by using the vararg keyword in the IDL in combination with an argument specified as SAFEARRAY(VARIANT), there is no support for specifying such a method in an MFC ActiveX project. You can do it with ATL instead, but I think this would be an enormous inconvenience just to get the functionality you describe.

Some better choices (in my opinion) would be:

  1. Provide specific methods for each of the use cases of your wrapped function.
  2. Provide a single method that exposes all arguments and add a UINT to set flags depending on which arguments should be used.

My choice would be 1.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top