Search code examples
boostwindows-servicesinterprocess

boost::interprocess between Windows service and user application


I'm using boost::interprocess to communicates between two applications. When the two applications are launch by the same user, it works great.

When one of the application is a service, it fails.

I found that the shared media is in fact a file that is created in the "TMP" directory. So it fails because each application is creating his own file in his own "TMP" directory.

Maybe I'm not using it the good way for my particular purpose.

Does anybody having a clue of how to solve my problem?

Thanks a lot,

Nic


EDIT: I tried using "managed_mapped_file". My problem is that the win32 implementation is calling "CreateFileMapping" without specifying a name for the object. In my special case, I think I need to specify something like "Global\MyMappedFile" so that both the application and the service can view the mapped file.


Solution

  • Here is something that works :

    • I'm using "boost::interprocess::managed_windows_shared_memory"
    • The name of my section is "Global\MySharedMemory"
    • I have to handle the case where the application is started and the service not. This is because even if my application can have read/write access to the shared memory, it can't create it. Only the service can. (In fact, the application can if and only if the user running it has a special privilege SeCreateGlobalPrivilege)

    Maybe somebody can find a better way ;-)

    Nic