SAMPLE: AutoCtrl.exe - OLE Automation Controller Sample

ID: Q106080

The information in this article applies to:

SUMMARY

AutoCtrl.exe demonstrates how to create an OLE automation controller.

MORE INFORMATION

The following file is available for download from the Microsoft Software Library:

 ~ AutoCtrl.exe (size: 27099 bytes) 

For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q119591
   TITLE     : How to Obtain Microsoft Support Files from Online Services

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 Methods

IDispatch::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.

Additional query words: Keywords : kbfile kbsample kbAutomation kbNTOS350 kbNTOS351 kbOLE200 kbWinOS95

Last Reviewed: December 11, 1998