Visual C++ 6 Unleashed

Visual C++ 6 Unleashed

By MICKEY WILLIAMS and David Bennett

Active Servers Introduction

This chapter discusses the three types of COM, OLE, and Active servers.

First is the full server. A full server is both an OLE or Active document server and a fully functioning application. In Microsoft Word, for example, you can run the application (as I am doing while writing these words), create a document or brochure, and then save the contents to a .DOC file. Or, you can open an application such as WordPad and actually embed or link to content that you've created using Microsoft Word.

The second type of server is known as a miniserver. What this means is that the server can be used only to supply content for a container application. As an example, Microsoft Word comes with myriad applets that can help you produce professional-looking documents. One of these applets is Microsoft WordArt. If you attempt to run the WordArt program, you'll get a message telling you that the application can be run only when launched from inside another application.

Now, we'll veer off in a totally different direction and talk about the third type of server. This is where things get a bit confusing for some folks. The third type of server—automation server—doesn't necessarily act or appear to be anything like the full server or miniserver. In fact, a simple automation server doesn't support OLE or Active document embedding at all. Instead, this type of server exposes special objects, methods, and properties to enable you to tell it what to do. For example, suppose that I want to take a mail-merge document that I created in Microsoft Word and merge it with a mailing list stored in a Microsoft Access database. Sure, I could open up Microsoft Word and select the mail merge menu item (along with performing about half a dozen other steps) and manually achieve my goal. Or, I could write an application in Visual C++ (or any other language that supports automation) and remotely control Microsoft Word. That way, I could set up the program so that it runs every day at 4 a.m., unattended, for example.

There are two flavors of automation servers: in-process and out-of-process.

In a nutshell, an in-process server is created from a class stored in a DLL, which is loaded and runs in the same process space as the application that created it. All instances share the same code; however, each has its own independent data area.

An out-of-process server runs in its own address space. This type of server is built as an EXE application (such as for Microsoft Word and Excel) and can either manage multiple instances or launch a new copy of the EXE each time a server object is created.

Okay, I know, it's a lot to grasp right now. Don't worry, though, because by the time you get through this chapter, I'm sure you'll have a much better grasp of how these different types of servers work.

Share ThisShare This

Informit Network