我在服务器端使用了这段代码
void Window_Loaded(object sender, RoutedEventArgs e)
{
HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
source.AddHook(new HwndSourceHook(WndProc));
}
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
// Handle messages...
var htLocation = DefWindowProc(hwnd, msg, wParam, lParam).ToInt32();
if (msg == 1)
{
MessageBox.Show("" + msg);
}
return new IntPtr(1);
}
我像这样从客户端发送消息
SendMessage(m_Process.MainWindowHandle, 1, (IntPtr)(-1), (IntPtr)(-1));
问题是服务器端收不到这个消息,为什么?