boost :: interprocess :: message_queue构造函数失败

时间:2013-01-24 20:49:07

标签: c++ boost boost-interprocess

当进程在不同用户下运行时,

boost :: interprocess :: message_queue构造函数失败 更具体。我正在proc1中创建message_queue。并尝试从proc2(另一个用户)打开相同的message_queue 是否有可能使其工作?或者我应该找到另一种方法来同步我的流程?

升压1.52
操作系统:Windows 7 x86
编译:MSVC 2010

P.S。代码很简单。如果两个进程都是从同一个用户启动的话,那么完全正常工作。

P.P.S。这是我收到的消息框。我无法调用LastWindowError()...

---------------------------
Error
---------------------------
Runtime Error (at 18:421):



External exception E06D7363.
---------------------------
ОК   
---------------------------

我的代码(Process2):

   void ipcMsg1(HWND hWnd) {
    util::MsgBox mb(hWnd, L"Sending Message1");
    try {
        mb.info(L"create mq");
        bipc::message_queue mq(bipc::open_or_create, plmqproto::g_mqName, plmqproto::g_mqSize, sizeof(int));
        mb.info(L"created");
        const int msg = plmqproto::g_mqMessage1;
        mq.send(&msg, sizeof(msg), 0);
        bipc::message_queue::remove(plmqproto::g_mqName);
    } catch(const bipc::interprocess_exception &ex) {
        mb.error(plcore::stringToWString(ex.what()));
        std::wstringstream ss;
        const unsigned long we = GetLastError();
        ss << L">1. GetLastError: " << we << std::endl;
        ss << L" " << plcore::GetWindowsErrorMessage(we); 
        mb.error(ss.str());
    } catch(const std::exception &ex) {
        mb.error(plcore::stringToWString(ex.what()));
        std::wstringstream ss;
        const unsigned long we = GetLastError();
        ss << L">2. GetLastError: " << we << std::endl;
        ss << L" " << plcore::GetWindowsErrorMessage(we); 
        mb.error(ss.str());
    } catch(...) {
        std::wstringstream ss;
        const unsigned long we = GetLastError();
        ss << L">3. GetLastError: " << we << std::endl;
        ss << L" " << plcore::GetWindowsErrorMessage(we); 
        mb.error(ss.str());
    }
}

因此。我只得到“创建mq”消息框。然后失败。

Boost升级没有帮助。

0 个答案:

没有答案
相关问题