|
Introduction
In recent years I've been reading about OLE. I've tried to absorb the
material as fast as I could although my progress seemed to be too slow due to the
vast diversity of the subject. I've been working on type libraries and dispatch
interfaces as well as generating interface codes for C++ programs (GenPro
project can be mentioned as a result of this work), but there is still so much to learn and it takes a long time. Anyway I felt that it would be a great idea to
develop small source codes and let the concept gradually sink in. Consequently I
decided to devote a page on OLE and provide simple examples in it. These
examples are written using pure C++ and without any framework such as OWL, OCF
or MFC. Concepts and design methods are based on the book INSIDE OLE by Kraig
Brockschmidt.
Examples
-
Simple Server, this example
demonstrates how to develop a simple COM/OLE server. The project
file consists of two targets, the one that builds the DLL server and
the one that uses it. One of the features of this server is that it
can register/unregister itself by implementing and exporting
DllRegisterServer and DllUnregisterServer functions. Thus one can
register the server by typing
regsvr32 simpserv.dll
on command line and unregister it by
regsvr32 simpserv.dll /u.
As I intend to add other features to this server,
I have modified it from the previous version in order to prepare the
scene for future extensions. If installed properly, this server exposes an interface that
can be used to draw a rectangle of different colors in the client
part of a given window. One can choose to modify the origin,
dimension and color of this rectangle using the methods of exposed
interface.
-
Dispatch Object,
in this example, it is shown how to turn a simple object, such as the
one in previous example, into an automation object. The steps are
straight forward and are obvious from the code. It is necessary to
add more information to the system registry and therefore extensive
changes to DllRegisterServer and DllUnregisterServer functions are
inevitable. In order to test the object, two applications are
provided. One is written using OWL and also the code generated by
GenPro and the other one is a simple VB script.
Last Updated: 12/26/2011
|