全局 sendmessage 得不到无返回值,该怎么解决

全局 sendmessage 得不到无返回值
大家好   棘手问题   请赐教     万分感谢。
我在程序A里写了if(!::SendMessage((HWND)HWND_BROADCAST,WM_STARTPIN,0,0))
{
          return   FALSE;
}
                                                    else       .....
在另外一个程序B里   实现这个消息:
const   UINT   WM_STARTPIN   =   ::RegisterWindowMessage(_T( "StartPin "));//声明
ON_REGISTERED_MESSAGE(WM_STARTPIN,   OnStartPin)//消息宏
下面是消息实现:
LRESULT   CThunSkeyDlg::OnStartPin(WPARAM   wp,   LPARAM   lp)
....
return   0;
else     return   1;

我就是想把0或者1   返回到程序A里  
用来判断if(!::SendMessage((HWND)HWND_BROADCAST,WM_STARTPIN,0,0))
但不管   return   0   还是return   1     这个if里的值都为假

多谢各位。


------解决方案--------------------
If the specified window was created by the calling thread, the window procedure is called immediately as a subroutine. If the specified window was created by a different thread, the system switches to that thread and calls the appropriate window procedure. Messages sent between threads are processed only when the receiving thread executes message retrieval code. The sending thread is blocked until the receiving thread processes the message. However, the sending thread will process incoming nonqueued messages while waiting for its message to be processed. To prevent this, use SendMessageTimeout with SMTO_BLOCK set. For more information on nonqueued messages, see Nonqueued Messages.

貌似应该 use SendMessageTimeout with SMTO_BLOCK set
------解决方案--------------------
全局SendMessage,只要对方接收并且处理了msg,那么返回就一定是真
也就是说你用返回值是无法拿到对方函数的返回的

但是你可以在对方执行完函数以后也调用一个SendMessage发回来一个自定义消息,告诉你他执行完毕
------解决方案--------------------
Applications that need to communicate using HWND_BROADCAST should use the RegisterWindowMessage function to obtain a unique message for inter-application communication.

The system only does marshalling for system messages (those in the range 0 to WM_USER). To send other messages (those above WM_USER) to another process, you must do custom marshalling.

If the specified window was created by the calling thread, the window procedure is called immediately as a subroutine. If the specified window was created by a different thread, the system switches to that thread and calls the appropriate window procedure. Messages sent between threads are processed only when the receiving thread executes message retrieval code. The sending thread is blocked until the receiving thread processes the message. However, the sending thread will process incoming nonqueued messages while waiting for its message to be processed. To prevent this, use SendMessageTimeout with SMTO_BLOCK set.

------解决方案--------------------
LRESULT SendMessage(
HWND hWnd, // handle to destination window
UINT Msg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);

一般成功返回 S_OK
S_OK == 0