Click here to Skip to main content
Click here to Skip to main content

DCOM D-Mystified: A DCOM Tutorial, Step 6

, 8 May 2005
Rate this:
Please Sign up or sign in to vote.
We build our new server and install it on the server machine.

Introduction

Welcome to Step 6 of our DCOM tutorial. In this series, I will strip the mystique, the headache, and confusion from DCOM by giving you a comprehensive tutorial with a straightforward example. OK, no promises -- but I will give it a good try.

If you want to follow along with this tutorial and add code and use the Visual C++ Wizards as we go along, that's great. In fact, I very very highly recommend that, because otherwise this tutorial is a big waste of electronic ink (?). However, I follow along exactly with the tutorial myself, as I write it, and develop the code and use the Visual C++ wizards just as I say you should. The screenshots, in fact, are from my development of the files for each step! To download this already-developed code to compare with your own, simply click the 'Download the Step n Files - n KB" links at the top of each step. There's also an archive of the files for all the steps at the Questions and Answers page for this tutorial. I still recommend that you follow along with me as we go; this way, you can learn while you code. If you ever have problems along the way with this tutorial, feel free to:

Remember, our steps in developing the software in this tutorial are as follows:

  • Step 1: Create the server, HelloServ, using the ATL COM AppWizard.
  • Step 2: Modify the starter files provided by the AppWizard.
  • Step 3: Use the New ATL Object Wizard to add a simple COM object, the HelloWorld object, to the server.
  • Step 4: Modify the IHelloWorld interface to include a SayHello() method.
  • Step 5: Add an event method, OnSayHello(), to the connection point source interface, DHelloWorldEvents.
  • Step 6: Build the server, and install it on the server computer.
  • Step 7: Create a MFC client, HelloCli, which calls the server and handles the connection point event sink.

We're currently on Step 6 of this tutorial, where we build the server and also build and register the Proxy-Stub DLL which goes along with it. Let's plunge in:

Step 6: Build the Server and Install It on the Server Computer

When you have reached this step, it's time to build our DCOM server, which is implemented as a Windows NT Service. Before we click that Build button, there are some things to do first. We start by making a few changes to the project settings, add a Custom Build Step to the project in order to build and register our Proxy-Stub DLL, and then we will make sure and change the configuration we're using. After doing all of this, we will be ready to click the Build button.

To change the project settings, click the Project menu, and then click Settings. Click the Custom Build tab; scroll over if you can't see it. Make sure you select the Win32 Release MinDependency configuration in the Settings For drop-down. After you've done that, erase everything in all of the fields of the Custom Build tab, so that what you have matches Figure 1 below:

Removing the Custom Build step in the Project Settings dialog box.

Figure 1. Removing the Custom Build step in the Project Settings dialog box.

Next, click the Post-Build Step tab. Again, before making changes, make sure you have the Win32 Release MinDependency configuration selected in the Settings For dropdown, as illustrated by Figure 2:

Making sure that Win32 Release MinDependency is selected.

Figure 2. Making sure that Win32 Release MinDependency is selected.

Then type Building and registering Proxy-Stub DLL... in the Post-Build Description box, and then type the following lines into the Post-Build Command(s) area, to match Figure 3:

start /wait nmake -f HelloServps.mk
regsvr32 HelloServps.dll

Specifying the Post-Build Step settings.

Figure 3. Specifying the Post-Build Step settings.

The last thing to make sure to do before beginning the build is to make sure that the right configuration is the active configuration. In our case, this is the Win32 Release MinDependency configuration. Click Build on the menu bar, and then click Set Active Configuration. This brings up the Set Active Configuration dialog box, as shown in Figure 4. Click the HelloServ - Win32 Release MinDependency entry in the listbox, and then click OK.

Selecting the Win32 Release MinDependency configuration.

Figure 4. Selecting the Win32 Release MinDependency configuration.

Building and Installing the Server, and Other Notes From the Rear

At last! Now we're ready to build. Click that good ol' Build button on the toolbar, and watch the magic happen. When everything's done, you should have a HelloServ.exe EXE file in the \ReleaseMinDepenedency subfolder of the project, and you should also see a HelloServps.dll DLL in the main project directory. Copy those two files to a floppy disk, and then put those in the C:\Winnt\System32\ directory on the computer you want to use as the server. Make sure the server machine is running Windows NT 4.0 Workstation or Server, or Windows 2000. Then, using the Run dialog box from the Start menu, run the following command lines, in this order:

  1. HelloServ /Service
  2. regsvr32 HelloServps.dll

Now, we'll use your development machine (the one you're following this tutorial with) as the client computer. To proceed, however, we'll need to follow these steps if the client machine is running either Windows NT 4.0 or Windows 2000:

  1. Copy the HelloServ.exe and HelloServps.dll files from the floppy disk to the C:\Winnt\System32\ directory of the client machine.
  2. Click the Start button, and then click Run.
  3. Run the command line HelloServ /Service.
  4. Click the Start button, and then click Run again.
  5. Run the command line regsvr32 HelloServps.dll.

If your client machine is not running either Windows NT or Windows 2000, then you have to follow these steps:

  1. Make sure that the DCOM98 extensions, available here, are installed.
  2. Copy the HelloServ.exe and HelloServps.dll files from the floppy disk to the C:\Windows\System directory of the client machine.
  3. Click the Start button, and then click Run.
  4. Run the command line HelloServ /RegServer.
  5. Click the Start button, and then click Run again.
  6. Run the command line regsvr32 HelloServps.dll.

Now we are ready to proceed with Step 7. To move to Step 7, click Next below. If you need to go back to Step 5, click Back. If you have questions or problems, try clicking Questions and Answers below to jump to a page which offers some help.

<< Back | Next >>

Questions and Answers

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Brian C Hart
Software Developer (Senior) Corrugated Technologies, Inc.
United States United States
From Fridley, Minnesota and I like computer programming! When I got started, I was working mostly with Windows GUI programming in C/C++. Then later on I worked with COM/DCOM for a school internship. I used COM/DCOM to write an ad hoc cluster server and job-running environment for a cluster of 24 Windows-based high-end visualization workstations. I moved on to C# and have been working in C# and Windows Forms ever since. I have yet to embrace Silverlight Smile | :)
Follow on   Twitter

Comments and Discussions

 
GeneralA nice tutorial but a little hard to follow PinmemberZhiwei Liu27-Apr-08 18:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 9 May 2005
Article Copyright 2000 by Brian C Hart
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid