コード例 #1
0
ファイル: bho_relas.cs プロジェクト: robber2000/icaller
 public int ie_add(int a, int b)
 {
     //初始化LED的SDK
     ImportFromDLL.InitSdk(2, 2);
     sendMsgToQt(a.ToString() + "4vv" + b.ToString());
     return(2222);
 }
コード例 #2
0
ファイル: bho_relas.cs プロジェクト: robber2000/icaller
        public int sendMsgToQt(string msg)
        {
            //WriteLog("toQt", msg);
            string strDlgTitle = "Form1";

            //did work
            SendString(strDlgTitle, 0, msg);

            //todo-test
            IntPtr hwndRecvWindow = ImportFromDLL.FindWindow(null, strDlgTitle);

            if (hwndRecvWindow == IntPtr.Zero)
            {
                //WriteLog("error", "请先启动接收消息程序");
                //MessageBox.Show("请先启动接收消息程序");
                return(100);
            }
            else
            {
                //WriteLog("log", "found recv message window...");
                //MessageBox.Show("找到窗口");
                // return 200;
            }

            //ImportFromDLL.FindWindow(null, strDlgTitle)
            IntPtr hwndSendWindow = ImportFromDLL.GetConsoleWindow();

            if (hwndSendWindow == IntPtr.Zero)
            {
                //WriteLog("error", "获取自己的窗口句柄失败,请重试");
                //MessageBox.Show("获取自己的窗口句柄失败,请重试");
                return(300);
            }

            for (int i = 0; i < 10; i++)
            {
                string strText = DateTime.Now.ToString();
                ImportFromDLL.COPYDATASTRUCT copydata = new ImportFromDLL.COPYDATASTRUCT();
                //copydata.cbData = Encoding.Default.GetBytes(strText).Length;
                copydata.cbData = 22;
                copydata.lpData = strText;

                ImportFromDLL.SendMessage(hwndRecvWindow, ImportFromDLL.WM_COPYDATA, hwndSendWindow, ref copydata);

                //WriteLog("success", strText);
            }
            return(999);
        }
コード例 #3
0
        public void sendMsgToQt(string msg)
        {
            WriteLog("toQt", msg);
            string strDlgTitle = "个人工作集成平台助手";

            //did work
            SendString(strDlgTitle, 0, "this is my msg");

            //todo-test
            IntPtr hwndRecvWindow = ImportFromDLL.FindWindow(null, strDlgTitle);

            if (hwndRecvWindow == IntPtr.Zero)
            {
                WriteLog("error", "请先启动接收消息程序");
                return;
            }
            else
            {
                WriteLog("log", "found recv message window...");
            }


            IntPtr hwndSendWindow = ImportFromDLL.GetConsoleWindow();

            if (hwndSendWindow == IntPtr.Zero)
            {
                WriteLog("error", "获取自己的窗口句柄失败,请重试");
                return;
            }

            for (int i = 0; i < 10; i++)
            {
                string strText = DateTime.Now.ToString();
                ImportFromDLL.COPYDATASTRUCT copydata = new ImportFromDLL.COPYDATASTRUCT();
                copydata.cbData = Encoding.Default.GetBytes(strText).Length;
                copydata.lpData = strText;

                ImportFromDLL.SendMessage(hwndRecvWindow, ImportFromDLL.WM_COPYDATA, hwndSendWindow, ref copydata);

                WriteLog("success", strText);
            }
        }