Пример #1
0
 public void SendStopTask()
 {
     if (WindowUtil.IsWindow(this._parentProcessHwnd) && (this._ieItem != null))
     {
         COPYDATASTRUCT copydatastruct;
         string         s      = "a";
         int            length = Encoding.Unicode.GetBytes(s).Length;
         copydatastruct.dwData = (IntPtr)2;
         copydatastruct.lpData = s;
         copydatastruct.cbDaat = length + 2;
         WindowUtil.SendMessage(this._parentProcessHwnd, (int)WindowsMessages.WM_COPYDATA, 0, ref copydatastruct);
     }
 }
Пример #2
0
 public void SendCompleteTask(int id, bool completed, int taskStep, string errorStr)
 {
     if (WindowUtil.IsWindow(this._parentProcessHwnd))
     {
         try
         {
             COPYDATASTRUCT copydatastruct;
             XmlDocument    document = new XmlDocument();
             XmlElement     newChild = document.CreateElement("root");
             XmlElement     element2 = document.CreateElement("taskid");
             XmlElement     element3 = document.CreateElement("isCompleted");
             XmlElement     element4 = document.CreateElement("errorString");
             XmlElement     element5 = document.CreateElement("taskStep");
             element2.InnerText = id.ToString();
             element3.InnerText = completed.ToString();
             element4.InnerText = errorStr;
             element5.InnerText = taskStep.ToString();
             newChild.AppendChild(element2);
             newChild.AppendChild(element3);
             newChild.AppendChild(element4);
             newChild.AppendChild(element5);
             document.AppendChild(newChild);
             string outerXml = document.OuterXml;
             int    length   = Encoding.Unicode.GetBytes(outerXml).Length;
             copydatastruct.dwData = (IntPtr)1;
             copydatastruct.lpData = outerXml;
             copydatastruct.cbDaat = length + 2;
             WindowUtil.SendMessage(this._parentProcessHwnd, (int)WindowsMessages.WM_COPYDATA, 0, ref copydatastruct);
             newChild = null;
             document = null;
         }
         catch (Exception)
         {
         }
     }
 }