SAMPLE: AutoCtrl.exe - OLE Automation Controller Sample

ID: Q106080


The information in this article applies to:
  • Microsoft OLE Libraries for Windows and Win32s, version 2.0
  • Microsoft OLE Libraries, used with:
    • Microsoft Windows NT, versions 3.5, 3.51
    • Microsoft Windows 95


SUMMARY

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


MORE INFORMATION

The following file is available for download from the Microsoft Download Center. Click the file name below to download the file:

AutoCtrl.exe
For 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.asp
and then click How to use the Microsoft Download Center.

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 kbGrpCom kbDSupport
Version : WINDOWS:2.0,95; :
Platform : WINDOWS
Issue type :


Last Reviewed: December 7, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.