OLE Servers Here we Come

by Stephan Grieger - GUI Computing

Visual Basic 4 opens some brand new vistas, with the ability of both the 16 bit and 32 bit versions will to create OLE Servers, and especially with the 32 bit version allowing us to create 'inprocess' Servers (or DLLs to you and me).

VB4 introduces a new type of module - the Class Module. It is within this module that you write the hooks into your OLE Server application. In the simplest case, you can write the application as thought it were any normal VB application, including Modules, forms, etc. Once the core application is written you would simply add the hooks into it via the Class Module. These can be what are effectively functions or a more complex object heirarchy.

For example, suppose in your OLE Server you had a form which you wanted to give a Show property. You would start of by developing the form as you would in VB 3. You would then add a class module with a name that is unique to this OLE Server. More about why a little later on. The code for this module would be as follows:

  Public Sub Show()
    MyForm.Show
  End Sub

Nothing to it really is there? The Public statement inside the Class Module tells VB that this function should be exposed to the outside world thereby creating the hook into, or property of, the OLE Server. Only public functions inside a Class Module are exposed.

O.K. so why did we give this Class Module a unique and Descriptive name? Well, apart from the obvious benefits, each Class Module inside your application is another OLE Server. In this way, we could have multiple OLE Servers in the one DLL. This not only increases the level of code reusability but also encourages the creation of Corporate OLE Servers which invoke business rules, etc.

Registering your new server is just as easy - when the application is first executed as an OLE Server, Visual Basic will automatically register the application inside the Registration Database. From then on in, this OLE Server can be used from within any other Windows Application that supports the OLE standard.

In fact itís quite a buzz when you create your first OLE Server and then have Excel bring it up as easily as if it were one of its own components.


Written by: Stephan Grieger
Aug 95



[HOME] [TABLE OF CONTENTS] [SEARCH]