开发者

Application does not receive broadcast message if running under the Visual Studio 2010 debugger

开发者 https://www.devze.com 2023-04-01 10:29 出处:网络
We are using registered Windows messages to communicate between instances of our application. We send the message using the following call:

We are using registered Windows messages to communicate between instances of our application. We send the message using the following call:

 DWORD dwResult;
 ::SendMessageTimeout(HWND_BROADCAST, wmRegisteredMessage, 0, 0, 
   SMTO_ABORTIFHUNG | SMTO_NORMAL,
   200,
   &dwResult);

This mechanism works fin开发者_如何学编程e as long as the application is not running under the Visual Studio 2010 debugger. If it is, the message handler does not get called. In addition, Spy++ shows that the application is not being sent the message.

If the application is running and the debugger is then attached to the process, the message is received as expected.

If the code is changed to:

SendMessage(HWND_BROADCAST, wmRegisteredMessage, 0, 0);

Everything works as expected.

I have tried different parameters to SendMessageTimeout() but I still see the same behavior. I added code to check the return code from SendMessageTimeout() and it does not return an error.

Any ideas?


Ajay is correct. It is a UAC problem. The debugger was running as an admin and the application sending the Windows message was not running as an admin. When I run this application as an admin the message is received correctly. The interesting thing is that SendMessage() does not appear to enforce the same security as SendMessageTimeout().

0

精彩评论

暂无评论...
验证码 换一张
取 消