Click here to Skip to main content
15,867,308 members
Articles / Desktop Programming / ATL

DCOM D-Mystified: A DCOM Tutorial, Step 6

Rate me:
Please Sign up or sign in to vote.
5.00/5 (15 votes)
8 May 2005CPOL 638K   3.4K   71   152
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)


Written By
Team Leader
United States United States
Brian C. Hart, Ph.D., is a strategic engagement leader on a mission to leverage space technology to protect U.S. interests and assets against adversaries. Throughout Dr. Hart's career, he has enjoyed: Working closely with business executives to provide strategic direction and leadership, translating customer and competitive intelligence into compelling capture strategies and solutions, and mentoring teams to enhance individual and company capabilities while fostering an engaging and accountable environment, being involved in STEAM initiatives and education to develop greater awareness in the community, and serving the armed forces with the U.S. Navy and U.S. Army National Guard. He is excited to begin developing his career in Jacobs's Critical Mission Systems business unit, supporting NORAD and the U.S. Space Force.

Comments and Discussions

 
GeneralDouble run on server side Pin
Member 197620814-Aug-08 21:48
Member 197620814-Aug-08 21:48 
GeneralRe: Double run on server side Pin
Brian C Hart15-Aug-08 7:47
professionalBrian C Hart15-Aug-08 7:47 
GeneralA nice tutorial but a little hard to follow Pin
Zhiwei Liu27-Apr-08 18:02
Zhiwei Liu27-Apr-08 18:02 
GeneralCompilation errors Pin
JockeP2-May-05 19:21
JockeP2-May-05 19:21 
GeneralRe: Compilation errors Pin
Brian C Hart2-May-05 21:19
professionalBrian C Hart2-May-05 21:19 
GeneralRe: Compilation errors Pin
JockeP3-May-05 1:09
JockeP3-May-05 1:09 
GeneralRe: Compilation errors Pin
Brian C Hart3-May-05 8:04
professionalBrian C Hart3-May-05 8:04 
GeneralMake Sure and Configure DCOM on Windows XP Pro SP2 Pin
Brian C Hart26-Mar-05 9:10
professionalBrian C Hart26-Mar-05 9:10 
GeneralClient registration Pin
AneesG16-Feb-05 23:44
AneesG16-Feb-05 23:44 
GeneralRe: Client registration Pin
Anonymous17-Feb-05 12:01
Anonymous17-Feb-05 12:01 
GeneralRe: Client registration Pin
stamsekar20-Nov-06 0:06
stamsekar20-Nov-06 0:06 
GeneralRe: Client registration Pin
Anonymous8-Sep-05 13:39
Anonymous8-Sep-05 13:39 
GeneralDon't Just Download Code - Work Through From Step 1 Pin
Brian C Hart9-Jan-05 23:14
professionalBrian C Hart9-Jan-05 23:14 
GeneralServer build failure Pin
4-Jun-04 10:12
suss4-Jun-04 10:12 
GeneralRe: Server build failure Pin
Brian C Hart4-Jun-04 14:56
professionalBrian C Hart4-Jun-04 14:56 
GeneralRe: Server build failure Pin
5-Jun-04 21:36
suss5-Jun-04 21:36 
GeneralRe: Server build failure Pin
Brian C Hart6-Jun-04 11:43
professionalBrian C Hart6-Jun-04 11:43 
GeneralRe: Server build failure Pin
Thuy Nguyenphuc6-Jun-04 13:21
Thuy Nguyenphuc6-Jun-04 13:21 
GeneralRe: Server build failure Pin
Brian C Hart6-Jun-04 17:31
professionalBrian C Hart6-Jun-04 17:31 
GeneralRe: Server build failure Pin
Thuy Nguyenphuc7-Jun-04 11:19
Thuy Nguyenphuc7-Jun-04 11:19 
I've tried with setting for "All Configurations", added "C:\Program Files\Microsoft Visual Studio\VC98\bin\VCVARS32.BAT" only. It built the EXE file without error, but the DLL was not built.

If I also added "start /wait nmake -f HelloServps.mk", and "regsvr32 HelloServps.dll" after the line of VCVARS32.BAT then I would get the same error of:

Building and registering Proxy-Stub DLL...
Bad command or file name
Cannot find file 'nmake' (or one of its components). Check
to ensure the path and filename are correct and that all
required libraries are available.
Bad command or file name
Error executing c:\windows\system32\command.com.


What did I miss?

Regards,

Thuy
GeneralRe: Server build failure Pin
nerill22-Jul-04 11:04
nerill22-Jul-04 11:04 
GeneralRe: Server build failure Pin
Brian C Hart22-Jul-04 12:01
professionalBrian C Hart22-Jul-04 12:01 
GeneralRe: Server build failure Pin
Brian C Hart22-Jul-04 11:58
professionalBrian C Hart22-Jul-04 11:58 
GeneralRe: Server build failure Pin
Brian C Hart22-Jul-04 11:59
professionalBrian C Hart22-Jul-04 11:59 
QuestionRe: Server build failure Pin
nikoladsp28-Nov-06 21:41
nikoladsp28-Nov-06 21:41 

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

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