Minimized Sample of DCOM Server

Environment: VC6 Win2K/NT/98

This out-of-process server can be called remotely by VC and VBScript clients through network. This 200-line full-featured DCOM project was built with pure Win32 API from scratch. The only function in this server is to double an integer.

For those who are not familiar with DCOM, in this sample, the client will call a function located on a remote machine in an exe file.

Steps to build and test the projects:

  1. Open MiniDcom.dsw, which contains MiniDcom.idl, Server.cpp, Client.cpp and Client.vbs.
  2. Build Server.dsp to get Server.exe, which is the DCOM server.
  3. Build Proxy.dsp to get Proxy.dll, which is the DCOM proxy and stub.
  4. Build Client.dsp to get Client.exe, which is the VC client.
  5. Run server.exe to register this component.
  6. Run “regsvr32 proxy.dll” to register the dll.
  7. Run client.exe. The client will call a function, which was implemented in server.exe and will be running in the server.exe’s process. Type in the machine name on which the server is located on (in this case, your computer’s name). Type in an integer and see the result. Please don’t close the client for now.
  8. Run another instance of client.exe and you can see the two clients share the single instance of the server.
  9. Run client.vbs, you can see that this DCOM server can be called by script language.
  10. Close all the three clients and the server should also disapear.
  11. If you want to run the client on a different machine, check the following:
    • “Ping server-machine-name” is fine.
    • Run dcomcnfg.exe on server machine to add the user account that runs the client.exe.
    • Copy proxy.dll to the client machine and register it by regsvr32.exe.


  1. Since the caller and callee are running in different process even different machines, the call has to cross process boundary. This job is done by proxy.dll, which can be generated automatically from the .idl file.
  2. To serve VBScript clients, IDispatch has to be implemented. We get it done through Type Library, which can be created automatically from .idl file.
  3. We register the server and the proxy-stub DLL so that the system can locate them by the CLSID.


Download demo project – 50 Kb

Download source – 8 Kb

More by Author

Must Read