OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Creating a DLL OLE Server

Converting an ObjectWindows EXE OLE server to a DLL OLE server requires only a few modifications.

The following topics discuss the tasks involved with building a DLL OLE server.

  1. Update Your Document Registration Table
  2. Compile and Link

Table Updating Your Document Registration Table

The document registration tables of DLL servers must contain the serverctx key with the string value "Inproc." This allows ObjectComponents to register your application as a DLL server with OLE. EXE servers do not need to use the serverctx key since ObjectComponents defaults to EXE registration.

The following code illustrates the document registration structure of a DLL server. It comes from the sample Tic Tac Toe program in EXAMPLES/OWL/OCF/TTT.

REGDATA(progid, "TicTacToeDll")
REGDATA(description,"TicTacToe DLL")
REGDOCFLAGS(dtAutoDelete | dtUpdateDir | dtCreatePrompt | dtRegisterExt)
REGDATA(verb0, "&Play")
REGFORMAT(0, ocrEmbedSource, ocrContent, ocrIStorage, ocrGet)
REGFORMAT(1, ocrMetafilePict, ocrContent, ocrMfPict, ocrGet)
#define ocrEmbedSource
Definition registry.h:638
#define REGDATA(var, val)
Definition registry.h:591
#define REGFORMAT(i, f, a, t, d)
Definition registry.h:594
#define REGDOCFLAGS(i)
Definition registry.h:598
#define BEGIN_REGISTRATION(regname)
Definition registry.h:583
#define END_REGISTRATION
Definition registry.h:589

You do not need to modify your application registration structure to convert your EXE server to a DLL server. It's a good idea, however, to use different clsid and progid values, especially if you intend to switch frequently from one type to the other. You can test for the BI_APP_DLL macro to declare a registration structure that works for both DLL and EXE servers; the macro is only defined when you are building a DLL. The following code shows a sample document registration which supplies two sets of progid and clsid values.

// Application registration structure
#if defined(BI_APP_DLL)
REGDATA(clsid, "{029442B1-8BB5-101B-B3FF-04021C009402}") // DLL clsid
REGDATA(progid, "TicTacToe.DllServer") // DLL progid
#else
REGDATA(clsid, "{029442C1-8BB5-101B-B3FF-04021C009402}") // EXE clsid
REGDATA(progid, "TicTacToe.Application") // EXE progid
#endif
REGDATA(description,"TicTacToe Application") // Description
// Document registration structure
#if defined(BI_APP_DLL)
REGDATA(progid, "TicTacToeDll")
REGDATA(description,"TicTacToe DLL")
#else
REGDATA(progid, "TicTacToe.Game.1")
REGDATA(description,"TicTacToe Game")
#endif
REGDATA(menuname, "TicTacToe Game")
REGDOCFLAGS(dtAutoDelete | dtUpdateDir | dtCreatePrompt | dtRegisterExt)
REGDATA(verb0, "&Play")
REGFORMAT(0, ocrEmbedSource, ocrContent, ocrIStorage, ocrGet)
REGFORMAT(1, ocrMetafilePict, ocrContent, ocrMfPict, ocrGet)
#define REGISTRATION_FORMAT_BUFFER(n)
Definition registry.h:603

Notice that the debugger keys (debugger, debugprogid, and debugdesc) are not used when building a DLL server. They are relevant only when your server is an executable that a debugger can load.

Compiling and linking a DLL OLE server

ObjectWindows DLL servers must be compiled with the large memory model. They must be linked with the OLE, ObjectComponents, and ObjectWindows libraries. The integrated development environment (IDE) chooses the right build options for you when you select Dynamic Library for Target Type and request OWL and OCF support from the list of standard libraries. You may choose to link with the static or dynamic versions of the standard libraries.

To build an ObjectWindows DLL server from the command line, create a short makefile that includes the OWLOCFMK.GEN file found in the EXAMPLES subdirectory. Here, for example, is the makefile that builds the sample program Tic Tac Toe:

DLLRES holds the base name of your resource file and the final DLL name. OBJDLL holds the names of the object files from which to build the sample. Finally, your makefile should include the OWLOCFMK.GEN file.

Name your file MAKEFILE and type this at the command-line prompt:

Make, using instructions in OWLOCFMK.GEN, builds a new makefile tailored to your project. The command also runs the new makefile to build the program. If you change the command to define MODEL as d, the above command will create a new makefile and then build your DLL using the DLL version of the libraries instead of the large model static libraries.

For more information about how to use OWLOCFMK.GEN, read the instructions at the beginning of MAKEFILE.GEN, found in the examples directory.