Now, we're ready to move the
and Atldept.dll
over to the remote machine that we'll call the server machine. On the 'server' machine, make sure that the network is prepared, including the activation of printer and file sharing, activation of the user level shares, and the enabling of DCOM connections if necessary. Having done this, create a Atlfinder.exe
directory on the 'server' machine and copy the following files into the directory:C:\Test
Atldept.dll
Atlfinder.exe
atl.dll
(from the ATL 2.1 distribution or your system directory)Regsvr32.exe
(from DevStudio\vc\bin
directory)
Now change directory to
and type in the following:C:\Test
REGSVR32 ATL.DLL
REGSVR32 ATLDEPT.DLL
ATLFINDER /RegServer
Each of these operations should complete successfully. Now install Object Viewer and start it up. Check under the All Objects list and find ATLFinder1 Class and ATLDept1 class. Double-click each one to ensure that you can create an instance of each class. Release the instances.
Finally, on the 'server' machine, type in
. This will start the ATLFINDER /Server
COM server listening for incoming COM requests. DCOM for Windows 95 doesn't support remote server launching. Therefore, all remote servers must be started manually. If you have a Windows NT 4.0 system, however, you'll not need to manually enter the above command. Atlfinder.exe
will be automatically launched on-demand under Windows NT DCOM.Atlfinder.exe
Now the 'server' machine is completely configured for operations. Go back to the 'client' machine. I assume that this machine has been properly configured as specified above, and that you've logged on with the same user ID as on the 'server' machine. Now, start up Object Viewer and click on the ATLFinder1 Class under All Objects. On the right-hand pane, you'll see a set of tabs. Click on the Implementation tab. Click on Local Server and you should see a path to the
on your system. Remove this path and leave the edit box empty. This effectively removes the content of the Atlfinder.exe
key from the registry. Now, we need to tell the 'client' machine that the LocalServer32
class is to be instantiated remotely. To do this, click on the Activation tab, click on the Launch As Interactive User and key in the IP address of the 'server' machine.ATLFinder1
Now go back to the left-hand pane and click on the ATLFinder1 Class entry to instantiate an object. If this is successful (it may take a little while), you'll see the interfaces listed and you'll have successfully instantiated an object across the network.
Important note: DCOM for Windows 95 is supposed to automatically start a program named
Rpcss.exe
when a connection is made to the object. However, this doesn't always work. If you have problems connecting to the object try running Rpcss.exe
on the 'server' before you attempt to connect.
To put the entire scenario to work now, open
from the last chapter. After a moment the calendar should start and display all the events. Try selecting a cell with events to get the details. Notice the response. Next, try changing months: notice again the significantly slower response. The ActiveX control is now working over the TCP/IP network via DCOM. The exact same interaction is happening across machine boundaries.TestPage.htm
The significant note to make here is that we haven't specifically programmed any DCOM server or DCOM client. The binary code hasn't actually changed at all. It's the same in-proc
server, the same Atldept.dll
local server, and the same ActiveX control. All we did was some external configuration, and our COM objects started to communicate with each other over the network. This is significant because it shows the fact that:Atlfinder.exe
DCOM is COM
Almost all legacy COM applications (ones designed with no consideration for DCOM) can be configured to work with DCOM. Of course, new 'from-scratch' applications can take specific advantage of the new features available in DCOM by programming directly to it or—more importantly—being designed specifically for it. We'll have a further discussion on these topics in a later section.
The following diagram depicts the interaction between the ActiveX control and the remote DCOM server components.