Colin,
If the parameters have default values, then that means that they are
also optional parameters. In order to get the default value to be used, you
should pass the value returned from the static Value property on the Missing
class in the System.Reflection namespace.
The only problem that you will run into is when an interface is not
completely automation-compliant. VB and MIDL compilers allow interfaces to
have optional parameters that were of a type other than a variant. If your
COM components are like this, then you will have a problem, I think, because
the optional parameter will be exposed as that type, and trying to pass
Missing.Value will throw a InvalidCastException (I believe).
In this case, you might want to do some reflection (in the COM sense) on
the type library, getting the type, and then looking at the method
information. You should be able to get what you need through the ITypeLib
and ITypeInfo (their .NET counterparts being UCOMITypeLib and UCOMITypeInfo)
interfaces.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"CMan" <cm**@nospam.nospam> wrote in message
news:Oy**************@TK2MSFTNGP10.phx.gbl...
Hi All,
I am trying to use a COM component that has methods with default
parameters. How can I call these methods from C#. Not all default values are in the
documentation of the control.
Thanks
Colin