Running an In-Proc Server Remotely

We can't just run ATLDept since it's a DLL. Instead we use a surrogate provided by DCOM. This is a program called

Dllhost.exe
and is installed by default in your
\Windows\System
directory during installation of DCOM for Windows 95. The operation of the surrogate process is quite straightforward: it simply creates a process space for the DLL server to execute in. It aggregates all of the DLL's interfaces and exposes them to any remote clients.

The command line syntax for invoking the surrogate is:

DLLHOST <clsid>

For example, we can host the

ATLDept.dll
by specifying the class id of the ATLDept class. (Note: one easy way to get the class id is to use Object Viewer, select the class and choose the Object menu, selecting the Copy CLSID to the clipboard option).

DLLHOST {D2A1CBC6-4C5E-11D0-8564-004005263AF7}

This will start the surrogate process waiting for DCOM calls on behalf of the

ATLDept.dll
server. If you examine the Implementation tab of the right pane of the Object Viewer display with the Inproc Server tab selected, you'll also see a space for specifying the surrogate process:

The entry here is rather useless under Windows 95. Under Windows NT, if you specify an entry here, the 'automatic launching' service can launch the

Dllhost.exe
surrogate with the
ATLDept.dll
whenever a client call is received remotely. On the other hand, starting such a surrogate must be performed manually on Windows 95. What's more interesting, if you were to instantiate ATLDept from Object Viewer, it would simply call the in-proc server directly without going through the expensive surrogate process.

© 1997 by Wrox Press. All rights reserved.