Any time you run the ATL Simple Object Wizard and choose Dual as the interface type, ATL generates an interface definition for the default interface that derives from IDispatch and is marked with the dual attribute, and places it in the IDL file. Because it derives from IDispatch, our dual interface can be used by scripting clients such as Active Server Pages (ASP), Internet Explorer (IE), and Windows Script Host (WSH). When our COM class supports IDispatch, we can use objects of that class from scripting environments. Here's an example HTML page that uses an instance of the CalcPi object:
<object class id=objPiCalculator> </object> <script language=vbscript> ' Set the digits property objPiCalculator.digits = 5 ' Calculate pi dim pi pi = objPiCalculator.CalcPi ' Tell the world! document.write "Pi to " & objPiCalculator.digits & _ " digits is " & pi </script>
For more information about how to handle the inconvenient data types associated with scriptingnamely, BSTRs and VARIANTssee Chapter 2, "Text and Strings," and Chapter 3, "ATL Smart Types."