Article ID: 107982 - Last Review: August 9, 2004 - Revision: 3.3 AutoDll.exe - OLE Automation Inproc ObjectThis article was previously published under Q107982 On This PageSUMMARY AutoDll.exe demonstrates how to create a OLE automation
inproc object. MORE INFORMATIONThe
following file is available for download from the Microsoft Download
Center: AutoDll.exe
(http://download.microsoft.com/download/win95upg/sample/2/w9x/en-us/autodll.exe)
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
(http://support.microsoft.com/kb/119591/EN-US/
)
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.
AutoDll.exe implements a OLE automation inproc object (DLL server) called Hello that exposes one property, HelloMessage, and one method, SayHello. It uses an OLE provided IDispatch implementation that is created using CreateStdDispatch. The AUTODLL dynamic-link library (DLL) uses the memory allocator used by the calling task. This is required of all inproc objects. The new and delete operators are redefined to use the calling task's memory allocator and all memory management is done using the redefined new and delete. The interface that AUTODLL 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. AUTODLL exports DllGetClassObject, which is called by OLE to get the class factory. OLE uses this classfactory to create a Hello object. Automation controllers use the IDispatch interface exposed by the Hello object to access its property and method. AUTODLL also exports DllCanUnloadNow. The SIMPAUTO sample in the Software/Data library demonstrates the implementation of an automation object with the same methods and properties as AUTODLL, but which is an EXE. The main differences between the two samples are in the MAIN.CPP file. To RunThe Hello object exposes the following:
Method and Property Names Notes
--------------------------------------------------------------
HelloMessage (prop) Sets and returns string.
SayHello (method) Displays HelloMessage in an edit
control.
To CompileRequires OLE 2.01 or later.Include device=vmb.386 in the [386Enh] section of SYSTEM.INI. NOTE: vmb.386 can be found in \OLE2\BIN. Run the WXSERVER.EXE from \OLE2\BIN before running the makefile.
File Function
------------------------------------------------------------------------
MAIN.CPP Does initialization, redefines new and delete, implements
DllGetClassObject, DllCanUnloadNow. 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.
| Article Translations
|
Back to the top
