public static mshtml.IHTMLDocument2 GetIEWindowDocument(IntPtr hwnd) { object ppvObject = new object(); int lParam = 0; Guid riid = new Guid(); int wMsg = WindowUtil.RegisterWindowMessage("WM_Html_GETOBJECT"); WindowUtil.ObjectFromLresult(WindowUtil.SendMessage(hwnd, wMsg, 0, lParam), ref riid, 0, ref ppvObject); mshtml.IHTMLDocument2 document = (mshtml.IHTMLDocument2)ppvObject; ppvObject = null; return(document); }
public void SendStopTask() { if (WindowUtil.IsWindow(this._parentProcessHwnd) && (this._ieItem != null)) { TaskBrowser.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, 0x4a, 0, ref copydatastruct); } }
public void SendCompleteTask(int id, bool completed, int taskStep, string errorStr) { if (WindowUtil.IsWindow(this._parentProcessHwnd)) { try { TaskBrowser.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, 0x4a, 0, ref copydatastruct); newChild = null; document = null; } catch (Exception) { } } }