1 //引用COM组件
2 //Microsoft HTML Object Library
3 //Microsoft Internet Controls
4
5
6
7 SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();
8 string filename;
9 foreach (SHDocVw.InternetExplorer ie in shellWindows)
10 {
11 filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
12 if (filename.Equals("iexplore"))
13 {
14 SetText(string.Format("Web Site : {0}", ie.LocationURL));
15 mshtml.IHTMLDocument2 htmlDoc = ie.Document as mshtml.IHTMLDocument2;
16 SetText(string.Format(" Document Snippet: {0}",
17 ((htmlDoc != null) ? htmlDoc.body.outerHTML
18 : "***Failed***")));
19 SetText(string.Format("{0}{0}", Environment.NewLine));
20 }
21 }