4.6 Calling a Method with Byref and Optional Arguments
This example shows a sequence of messages between an automation client and a server to call a method with a byref and an optional argument. The signature of the function is:
HRESULT test ([in, optional] VARIANT A, [in, out, optional] VARIANT *B);
The client calls the GetIDsOfName method on the server for the method named test. The server returns the DISPID (section 2.2.32) in the pointer passed by the client.
The client calls the Invoke method, filling the parameters as shown in the following figure. In the following example, the client is not passing any value for the first optional argument; thus, the VARIANT in rgVarg has to have the field vt set to VT_ERROR and scode set to DISP_E_PARAMNOTFOUND. rgVarg has the vt field set to VT_EMPTY. rgVarRef is a VARIANT with the VT_BYREF bit flag set.
On return from Invoke, rgVarRef with the server-updated value is passed back to the client.
Figure 8: Calling a method with Byref and optional arguments
Note For brevity, the Invoke method's dispid, riid, and lcid parameters are not shown.