The information in this article applies to:
SUMMARY
OPTARG is an OLE Automation server application that demonstrates
automation methods with optional parameters and variable number of
parameters. It implements an Add method that takes optional parameters
and a Multiply method that takes a variable number of parameters. MORE INFORMATIONThe following file is available for download from the Microsoft
Download Center. Click the file name below to download the file: Optarg.exeFor more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center. Optional parameters are implemented by marking the parameter with the optional attribute and by using VARIANT as the type of the parameter. If the controller omits a parameter, the method will be passed a VARIANT with VARIANT.vt = VT_ERROR and VARIANT.scode = DISP_E_PARAMNOTFOUND. Variable parameters are implemented by marking the method with the vararg attribute and by providing a parameter of type SAFEARRAY(variant). This array will contain the variable number of parameters passed by the controller. NOTE: vararg methods do not have the upper limit of parameters that methods with optional parameters do. Because of a problem in the OLE dlls, invoking the Multiply method will cause an exception in the 32-bit OLE that shipped with Windows NT 3.5 and a GP fault in 16-bit OLE 2.02 and 2.03. This problem has been fixed in NT 3.51 and Windows 95. The problem occurs if a vararg method has a retval parameter. For example, the following will fail:
The problem does not occur if the vararg method doesn't have a retval
parameter. For example, the following will currently work:
Additional query words: arguments 3.50 4.00 kbfile
Keywords : kbsample kbAutomation kbNTOS350 kbOLE200 kbWinOS95 kbGrpCom kbDSupport |
Last Reviewed: December 7, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |