应用程序结果受到另一个正在运行的应用程序的影响
这是我的上一个问题的后续问题,尽管这是关于其他事情的。
我一直遇到一个问题,由于某种原因,我从一个进程传递到另一个进程的消息仅显示第一个字母,在本例中为“M”。
我的应用程序基于 MSDN 示例因此,为了确保我没有错过任何东西,我创建了一个单独的解决方案,添加了 MSDN 示例(没有根据我的需要进行任何更改),不出所料,它工作得很好。
现在奇怪的是,当我运行 MSDN 示例(如在调试中)并运行我自己的应用程序时,文本打印得很好,没有任何问题。第二次我在没有打开原始 MSDN 示例的情况下自行运行它,它无法工作并且仅显示“M”。
我查看了调试器,似乎没有注意到任何可疑的东西(这是一张稍微过时的图片,我已经修复了数据类型不一致的问题)。
任何人都可以提供解决方案吗?我以前从未遇到过这样的事情。 要查看我的源代码,只需查看我在问题顶部发布的链接就更容易,我没有必要将其发布两次。
感谢您的帮助。
编辑:
经过进一步调查,我自己的应用程序似乎意外地读取了其他应用程序的内存。如果我“轮询”消息,甚至没有通过生产者窗口发送消息,它仍然会收到消息,这一定意味着它正在从其他(MSDN)进程中读取消息,这也解释了为什么它只有在我运行 MSDN 时才能正常工作先取样。
我仍然不明白为什么会发生这种情况,如何阻止它以及如何修复它,这可能是我遇到的最奇怪的事情。
****解决方案:****
虽然它不能解决两个应用程序相互影响的问题,但我已经设法解决了文本问题。我没有向这两个文件添加必要的 #include,添加此文件修复了它,没有任何警告。
总是小事。
This is a follow on from my previous question although this is about something else.
I've been having a problem where for some reason my message that I pass from one process to another only displays the first letter, in this case "M".
My application based on a MSDN sample so to make sure I hadn't missed something I create a separate solution, added the MSDN sample (without any changes for my needs) and unsurprisingly it works fine.
Now for the weird bit, when I run the MSDN sample running (as in debugging) and have my own application running, the text prints out fine without any problems. The second I run my on its own without the original MSDN sample being open it fails to work and only shows an "M".
I've looked in the debugger and don't seem to notice anything suspicious (it's a slightly dated picture, I've fixed the data type inconsistency).
Can anyone provide a solution as to this? I've never encountered anything like this before.
To look at my source code it's easier to just look at the link I posted at the top of the question, there's no point in me posting it twice.
Thank you for any help.
Edit:
After further investigation it almost seems that my own application is somehow reading the other applications memory by accident. If I "poll" for the message without even sending it via the producer window, it still gets the message which must mean it's reading it from the other (MSDN) process, this would also explain why it only works properly when I run the MSDN sample first.
I still don't understand why this happens, how to stop it and how to fix it, this is possibly the strangest thing I've come across.
****Solution:****
Although it does not fix the problem of both applications affecting each other I have managed to fix the text problem. I did not add the necessary #include to both files, adding this fixed it without any warnings.
It's always the little things.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在“内存查看器”窗口中查看
pBuf
。字符串查看器将在第一个空终止符处终止,但超出的内容可能很有趣/有用或提供线索。Take a look at
pBuf
in the "memory viewer" window. The string viewer will terminate at the first null terminator, but what lies beyond may be interesting/useful or provide a clue.