SAMPLE: OLE Automation Controller Sample

Last reviewed: August 5, 1996
Article ID: Q106080
The information in this article applies to:
  • Microsoft OLE Libraries for Windows and Win32s, version 2.0
  • Microsoft OLE Libraries, included with:

        - Microsoft Windows NT, versions 3.5 and 3.51
        - Microsoft Windows 95
    

SUMMARY

AUTOCTRL demonstrates how to create an OLE automation controller.

You can find AUTOCTRL.EXE (size: 27099 bytes) 
                         , a self-extracting file, on these services:

  • Microsoft's World Wide Web site on the Internet

          On the www.microsoft.com home page, click the Support icon
          Click Knowledge Base, and select the product
    
          Enter kbfile AUTOCTRL.EXE (size: 27099 bytes) 
                                   , and click GO!
          Open the article, and click the button to download the file
    
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the Softlib/Mslfiles folder
          Get AUTOCTRL.EXE (size: 27099 bytes) 
    
  • The Microsoft Network

          On the Edit menu, click Go To, and then click Other Location
          Type "mssupport" (without the quotation marks)
          Double-click the MS Software Library icon
          Find the appropriate product area
          Locate and Download AUTOCTRL.EXE
    
  • Microsoft Download Service (MSDL)

          Dial (206) 936-6735 to connect to MSDL
          Download AUTOCTRL.EXE (size: 27099 bytes) 
    

    For additional information about downloading, please see the following article in the Microsoft Knowledge Base:

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

    MORE INFORMATION

    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 reference words: 2.00 3.50 4.00 softlib AUTOCTRL.EXE
    KBCategory: kbole kbfile kbwebcontent
    KBSubcategory: LeTwoAto


    THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

    Last reviewed: August 5, 1996
    © 1998 Microsoft Corporation. All rights reserved. Terms of Use.