Article ID: 106080 - Last Review: August 10, 2004 - Revision: 3.2 SAMPLE: AutoCtrl.exe - OLE Automation Controller SampleThis article was previously published under Q106080 On This PageSUMMARY AutoCtrl.exe demonstrates how to create an OLE automation
controller. MORE INFORMATIONThe
following file is available for download from the Microsoft Download
Center: AutoCtrl.exe
(http://download.microsoft.com/download/win95upg/sample/1/w98/en-us/autoctrl.exe)
For
additional information about how to download Microsoft Support files, click the
following article number to view the article in the Microsoft Knowledge Base: 119591
(http://support.microsoft.com/kb/119591/EN-US/
)
How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most
current virus-detection software that was available on the date that the file
was posted. The file is stored on security-enhanced servers that help to
prevent any unauthorized changes to the file.
This OLE automation controller sample demonstrates how to create an OLE automation object and how to access its properties and methods. Creating an Automation Object[CreateObject() in file AUTOCTRL.CPP.]The user is prompted for the ProgID of the automation object to be created. CLSIDFromProgID is used to obtain the CLSID of the object; CoCreateInstance is used to create the object. Accessing Properties and MethodsIDispatch::GetIDsOfNames is used to obtain the ID of the property or method to be accessed; IDispatch::Invoke is used to access the property or method. This controller prompts the user for the locale ID; however, many controllers such as Visual Basic use the default system locale ID.Setting a Property[See SetProperty() in AUTOCTRL.CPP.]The user is prompted for the property name, property value, property type and locale ID. This controller supports three types: VT_BSTR, VT_I2 and VT_R4. Setting the property requires an implicit named parameter, which represents the new value of the property. The DISPID of this implicit named parameter is DISPID_PROPERTYPUT. Getting a Property[See GetProperty() in AUTOCTRL.CPP.]The user is prompted for the property name, property type, and locale ID. Invoking a Method[See InvokeMethod() in AUTOCTRL.CPP.]The user is prompted for the method name and the locale ID. This controller supports only methods without parameters. | Article Translations
|
Back to the top
