If I call a method of a COM object through IDispatch (late-binding) with the wrong number/types of arguments, will some error code be returned, or will the program crash or have other malfunctions? I just want to know if late-binding with IDispatch is type-safe.
Share
It depends from the actual implementation of the
Invokemethod ofIDispatch; it may check if the parameters passed inpDispParamsare correct or blindly use them, ignore the COM errors that arise from manipulating them in a wrong way or report these errors to the caller, …Still, if the interface you are calling uses the default
DispInvokefunction to implementIDispatch::Invokeyou should be safe, since it implements reasonable sanity checks on the arguments.