SAMPLE: Simple OLE Automation Object SampleLast reviewed: August 5, 1996Article ID: Q107981 |
The information in this article applies to:
SUMMARYSIMPAUTO demonstrates how to create a simple OLE automation object.
You can find SIMPAUTO.EXE (size: 27995 bytes) , a self-extracting file, on these services: On the www.microsoft.com home page, click the Support icon Click Knowledge Base, and select the product Enter kbfile SIMPAUTO.EXE (size: 27995 bytes) , and click GO! Open the article, and click the button to download the file ftp ftp.microsoft.com Change to the Softlib/Mslfiles folder Get SIMPAUTO.EXE (size: 27995 bytes) 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 SIMPAUTO.EXE Dial (206) 936-6735 to connect to MSDL Download SIMPAUTO.EXE (size: 27995 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 INFORMATIONSIMPAUTO implements a simple OLE automation object called Hello that exposes one property, HelloMessage, and one method, SayHello. It uses an OLE-provided IDispatch implementation that is created using CreateStdDispatch. The interface that SIMPAUTO exposes is described using an object description language (HELLO.ODL). The mktyplib tool is used to create a type library (HELLO.TLB) from HELLO.ODL. CreateStdDispatch() is then used to implement an IDispatch interface using the interface description in the type library. SIMPAUTO registers a class factory if it is started with the -Automation command-line switch. OLE uses this classfactory to create a Hello object. Automation controllers uses the IDispatch interface exposed by the Hello object to access its property and method. The AUTODLL sample in the Software Library demonstrates the implementation of an inproc automation object with the same methods and properties as SIMPAUTO, but which is a DLL. The main differences between the two samples are in the MAIN.CPP file.
To RunThe Hello object exposes the following:
ProgID : SimpleAutomation.Hello Method and Property Names Notes -------------------------------------------------------------- HelloMessage (prop) Sets and returns string. SayHello (method) Displays HelloMessage in an edit control.Update the HELLO.REG file in two places to include the full path information to the HELLOEXE and the HELLO.TLB files. Change the lines from the following:
LocalServer = hello.exe -Automation win16 = hello.tlbto something similar to the following:
LocalServer = c:\source\simpauto\hello.exe -Automation win16 = c:\source\simpauto\hello.tlb To CompileRequires OLE 2.01 or later. Include device=vmb.386 in the [386Enh] section of SYSTEM.INI. Note that vmb.386 can be found in \OLE2\BIN. Run the WXSRVER.EXE from \OLE2\BIN before running the makefile.
Files
MAIN.CPP Does initialization, creates main window, contains message retriever, and contains code that calls CreateStdDispatch. HELLO.CPP Implements the HELLO object.HELLOCF.CPP Implements the HELLO class factory. HELLO.ODL Object description Language that describes the property and method that HELLO exposes. HELLO.H Defines the HELLO object and the class factory. TLB.H Header file created by mktyplib. MAKEFILE Makefile for project.VB.MAK, VB.FRM Visual Basic project files to control this sample. |
Additional reference words: 2.00 3.50 4.00 softlib SIMPAUTO.EXE
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |