English 中文(简体)
boost::interprocess在Windows服务和用户应用程序之间
原标题:
  • 时间:2009-01-28 18:59:28
  •  标签:

我正在使用 boost::interprocess 在两个应用程序之间进行通信。当这两个应用程序由同一个用户启动时,它运行得很好。

当其中一个应用程序是服务时,它会失败。

我发现共享的媒体实际上是在“TMP”目录中创建的文件。因此,由于每个应用程序都在自己的“TMP”目录中创建自己的文件,所以它失败了。

可能我没有用对它实现我的特定目的。

有人知道怎么解决我的问题吗?

非常感谢。

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 "GlobalMyMappedFile" so that both the application and the service can view the mapped file.

最佳回答

这里有一些能发挥作用的东西:

  • I m using "boost::interprocess::managed_windows_shared_memory"
  • The name of my section is "GlobalMySharedMemory"
  • 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)

或许有人能找到更好的方法;-)

Nic(尼克)

问题回答

it s something about the Window Stations and ACL. you need to modify the source to make it work between windows service and user application. in vista and win7, services run at winsta0, but applications at winsta1. so you need to give a LPSECURITY_ATTRIBUTES with the right DACL.





相关问题
热门标签