Click here to Skip to main content
15,867,453 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

 
GeneralRPC Server Unavailable Pin
bollwerj16-Jun-03 8:48
bollwerj16-Jun-03 8:48 
GeneralRe: RPC Server Unavailable Pin
abhinarulkar6-Jul-03 18:26
abhinarulkar6-Jul-03 18:26 
GeneralRe: RPC Server Unavailable Pin
vokuit002-Sep-03 23:33
vokuit002-Sep-03 23:33 
GeneralRe: RPC Server Unavailable Pin
Brian C Hart19-Sep-03 9:14
professionalBrian C Hart19-Sep-03 9:14 
GeneralRe: RPC Server Unavailable Pin
cherrymarcc10-Nov-03 23:42
cherrymarcc10-Nov-03 23:42 
GeneralRe: RPC Server Unavailable Pin
manfie11-Nov-03 4:35
manfie11-Nov-03 4:35 
GeneralRe: RPC Server Unavailable Pin
Brian C Hart11-Nov-03 6:57
professionalBrian C Hart11-Nov-03 6:57 
GeneralRe: RPC Server Unavailable Pin
manfie12-Nov-03 5:20
manfie12-Nov-03 5:20 
GeneralRe: RPC Server Unavailable Pin
Brian C Hart12-Nov-03 7:26
professionalBrian C Hart12-Nov-03 7:26 
GeneralRe: RPC Server Unavailable Pin
Brian C Hart11-Nov-03 6:54
professionalBrian C Hart11-Nov-03 6:54 
GeneralRe: RPC Server Unavailable Pin
Brian C Hart24-Dec-03 9:22
professionalBrian C Hart24-Dec-03 9:22 
GeneralCan't link HelloServps.dll Pin
shd419110-Jun-03 16:12
shd419110-Jun-03 16:12 
GeneralRe: Can't link HelloServps.dll Pin
Brian C Hart6-Jun-04 11:57
professionalBrian C Hart6-Jun-04 11:57 
GeneralInterface not registered Pin
UTEK3-Jun-03 11:22
UTEK3-Jun-03 11:22 
GeneralRe: Interface not registered Pin
Brian Hart24-Jun-03 19:51
Brian Hart24-Jun-03 19:51 
GeneralRe: Interface not registered Pin
Brian C Hart24-Dec-03 9:31
professionalBrian C Hart24-Dec-03 9:31 
QuestionCan it be done automatically? Pin
junh14-May-03 3:24
junh14-May-03 3:24 
AnswerRe: Can it be done automatically? Pin
Brian Hart24-Jun-03 19:55
Brian Hart24-Jun-03 19:55 
Questionhow i remove a method from object Pin
Ptadeep12-Mar-03 3:52
Ptadeep12-Mar-03 3:52 
AnswerRe: how i remove a method from object Pin
Brian C Hart6-Jun-04 12:03
professionalBrian C Hart6-Jun-04 12:03 
GeneralUninstalling server Pin
Hare_07115-Jan-03 6:24
Hare_07115-Jan-03 6:24 
GeneralRe: Uninstalling server Pin
Jason Henderson15-Jan-03 6:26
Jason Henderson15-Jan-03 6:26 
GeneralRe: Uninstalling server Pin
Brian Hart24-Jun-03 19:56
Brian Hart24-Jun-03 19:56 
GeneralProblem with CoInitializeEx function Pin
Piter14-Dec-02 7:52
Piter14-Dec-02 7:52 
GeneralRe: Problem with CoInitializeEx function Pin
Brian Hart24-Jun-03 19:59
Brian Hart24-Jun-03 19:59 

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.