Microsoft KB Archive/106080

From BetaArchive Wiki

Article ID: 106080

Article Last Modified on 8/10/2004



APPLIES TO

  • Microsoft OLE 2.0
  • Microsoft OLE 4.0, when used with:
    • Microsoft Windows NT 4.0
    • Microsoft Windows NT 3.51 Service Pack 5
    • Microsoft Windows 95



This article was previously published under Q106080

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:

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 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 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: AutoCtrl

Keywords: kbfile kbautomation kbsample KB106080