Every of us developers had sometime needs for communication between two processes. Either we need to start new process as a different user or to communication with installed service or even to share some data with process on the other computer in local network or over the Internet. In all those cases we need to involve some way of communication between two different processes – IPC.
In this post, I’m going to touch some solutions when the both processes are running on the same computer.
Why we need IPC?
With the Windows Vista we got User Elevation confirmation (popular named UAC dialog – User Account Dialog), that is more-less extended version of RunAs from Windows XP. New User Elevation is very simple – even when the user is a Local Administrator, programs are started with Limited privileges – some kind of virtual Administrator without real Admin rights. That process can’t change some system settings (e.g. Registry keys), can’t write to the system files nor to start/stop services. To do that, process must get Admin rights which mean that user must confirm UAC dialog.
You can enforce to start your program with Elevated rights by adding correct manifest and this will prompt user on every start for UAC confirmation - no, we don’t want that. Those system modifications are not required every time that application is in use, and what if we want to have system tray app – UAC on windows start is not “cool” at all.
Solution : Start program as a normal (non elevated) user, and when we need admin rights we could start another process that will do “dirty” job for us. And there comes need to talk with that second process – that is why we need IPC
Basic “IPC”
We could start second process that will do something for us, and wait until is finished. As a return value we could get process return code and we can transfer our data to that process over command line parameters. It is easy, and unfortunately many developers using this way for communication between two processes. I say unfortunately because this method is not effective, it’s one-way only and the only it remind me on Post It note on my keyboard from my wife when I have to do something.
And what about more complex tasks, or case when second process must “ask” something?
Advanced IPC Solutions
There are many different advanced solutions:
- Windows Messages
- Shared Memory
- COM
- Local Procedure Call (LPC)
- XML/JSON RPC (Remote Procedure Calls)
- Windows RPC
- Named Pipes
- TCP/IP
- CORBA

No Comments » 