Minimized Sample of DCOM Server | CodeGuru

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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Sep 20, 2001
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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.

Architecture:

  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.

Downloads

Download demo project – 50 Kb

Download source – 8 Kb

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.