Partager via


3.1.4.4.3 Handling Default Value and Optional Arguments

For any arguments that the automation client does not semantically need to specify that correspond to defaultvalue parameters, the automation client MUST<56> use the value specified in the defaultvalue attribute.

For any arguments that the automation client does not semantically need to specify, that correspond to optional parameters, the automation client MUST use the "optional argument marker". The "optional argument marker" is a VARIANT value with the discriminant field set to VT_ERROR and the scode field set to DISP_E_PARAMNOTFOUND.

A method with the vararg attribute does not specify optional arguments by position. To pass arguments that do not correspond to positional arguments, the automation client MUST create a one-dimensional SAFEARRAY of VARIANTs whose length is the number of additional arguments, package the values of the arguments as VARIANTs in the SAFEARRAY, and pass the SAFEARRAY as the first argument in pDispParams. The automation client MUST pass an empty SAFEARRAY as the final argument of a vararg method if it does not need to specify any optional arguments.