private static extern int SendMessage( IntPtr hWnd, // 信息发往的窗口的句柄 int Msg, // 消息ID int wParam, // 参数1 ref HdCAD_lParam lParam );
public static void SendMsg(string lpWindowName, string msg) { IntPtr ptr = FindWindow(null, lpWindowName);//获取接收消息的窗体句柄 //消息构建 HdCAD_lParam m = new HdCAD_lParam(); m.s = msg; m.i = m.s.Length; SendMessage(ptr, HDCAD_MESSAGE, 1, ref m);//发送消息 }