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:
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:
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
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.
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:
- HelloServ /Service
- 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:
- Copy the HelloServ.exe and HelloServps.dll files from the floppy disk to the C:\Winnt\System32\ directory of the client machine.
- Click the Start button, and then click Run.
- Run the command line HelloServ /Service.
- Click the Start button, and then click Run again.
- 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:
- Make sure that the DCOM98 extensions, available here, are installed.
- Copy the HelloServ.exe and HelloServps.dll files from the floppy disk to the C:\Windows\System directory of the client machine.
- Click the Start button, and then click Run.
- Run the command line HelloServ /RegServer.
- Click the Start button, and then click Run again.
- 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
Dr. Brian Hart obtained his Ph.D. in Astrophysics from the University of California, Irvine, in 2008. Under Professor David Buote, Dr. Hart researched the structure and evolution of the universe. Dr. Hart is an Astrodynamicist / Space Data Scientist with Point Solutions Group in Colorado Springs, CO, supporting Space Operations Command, United States Space Force. Dr. Hart is a Veteran of the U.S. Army and the U.S. Navy, having most recently served at Fort George G. Meade, MD, as a Naval Officer with a Cyber Warfare Engineer designator. Dr. Hart has previously held positions at Jacobs Engineering supporting Cheyenne Mountain/Space Force supporting tests, with USSPACECOM/J58 supporting operators using predictive AI/ML with Rhombus Power, and with SAIC supporting the Horizon 2 program at STARCOM. Dr. Hart is well known to the community for his over 150 technical publications and public speaking events. Originally from Minneapolis/Saint Paul, Minnesota, Dr. Hart lives in Colorado Springs with his Black Lab, Bruce, and likes bowling, winter sports, exploring, and swimming. Dr. Hart has a new movie coming out soon, a documentary called "Galaxy Clusters: Giants of the Universe," about his outer space research. The movie showcases the Chandra X-ray Observatory, one of NASA’s four great observatories and the world’s most powerful telescopes for detecting X-rays. The movie has been accepted for screening at the U.S. Air Force Academy ("USAFA" for short) Planetarium and will highlight how scientists use clusters of galaxies, the largest bound objects in the Universe, to learn more about the formation and evolution of the cosmos --- as well as the space telescopes used for this purpose, and the stories of the astronauts who launched them and the scientists who went before Dr. Hart in learning more about the nature of the Universe.