Interprocess Communication Using the Running Object Table (ROT) | CodeGuru

Interprocess Communication Using the Running Object Table (ROT)

Introduction This article describes a simple technique to share data across multiple processes running on the same machine using the Running Object Table (ROT from here on). Scenario You must have come across scenarios where you need to share data across multiple applications quite often. Various approaches are available to share data: Using memory mapped […]

Written By
CodeGuru Staff
CodeGuru Staff
Jun 11, 2004
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

Introduction

This article describes a simple technique to share data across multiple processes running on the same machine using the Running Object Table (ROT from here on).

Scenario

You must have come across scenarios where you need to share data across multiple applications quite often. Various approaches are available to share data:

  1. Using memory mapped files.
  2. Clipboard.
  3. DDE and so on.

All these methods are no doubt effective in the context they were intended, but come with certain basic problems. Synchronizing access to the data, ensuring client and server are alive and healthy at various stages, packing, and unpacking data from whatever custom formats are used and so forth.

To avoid this headache, I have come upon a pretty simple approach to sharing data. Basically, what this entails is that each process, when launched, creates a single instance of a common component, ICommHelper, and adds this interface with the ROT using a Server Name prefixed with a filter (a hard coded string). I prompt the user for a server name; you would probably need to come up with an algorithmto generate the Server Name based on the application name, instance handle, process ID, server that the user has logged in to (if it is a client/server app), as a moniker. The ICommHelper interface provides methods to add and remove itself from the ROT.

The AppViewer process can enumerate the ICommHelper interfaces present in the ROT using the prefixed filter, and from this can get the Server name of the SampleServer process. So, the user can enumerate the SampleServer instances running on the machine. If the user wants to send data from the AppViewer (to any SampleServer) process, the AppViewer process queries the ROT to retrieve the ICommHelper interface pointer registered by the selected SampleServer application.

Once the ICommHelper interface is retrieved, the AppViewer can invoke the SendData method to transfer data to the selected SampleServer process. (The action to be performed by the SampleServer application, which will need to be modified as per your requirements, of course. This can be done synchronously or asynchronously.)

And voilà—your data has been transferred!

And, whenever the target application shuts down, the IRProcComm interface will need to be removed from the ROT.

Advertisement

Source Code Layout

  1. IPCHelper—DLL that hosts the COM Component IProcComm.
  2. TargetApp—MFC Dialog application that creates an instance of IProcComm and registers it with the ROT.
  3. SourceApp—MFC Dialog application that retrieves the IProcComm interface from the ROT and invokes the SendData method.
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.