By using memory-mapped files it is possible to implement an inter-process communication. You will see the basic concept of memory-mapped files in two previous articles:
- Inter-Process Communication with Memory-Mapped Files, Part 01: transfer a data structure and an object
- Inter-Process Communication with Memory-Mapped Files, Part 02: serialisation and thread-safe access
As I have implemented a little communication framework based on memory-mapped files I run into the following issue: The communication between two desktop applications was possible, but it was not possible to create a connection between a windows service and a desktop application.
The windows service and the desktop application are running in different security contexts. Therefore two different local mutex and memory-mapped file objects will be created. But this issue can be solved very easily. The mutex and the memory-mapped file must be created as global objects. To do this the names must have the prefix “Global\”. If this prefix is not used, the default prefix “Local\” will be used and different local objects will be created in each security context.