熟悉SHDocVw的进来看看
我有一个简单程序,在安装了VS2008的机器上运行正常,但是在没有安装VS2008,只安装.Net FrameWork3.5的机器上运行异常,请大家帮忙看一看,谢谢。分不够,再加!
首先,添加对ShDocVw的引用,然后在程序中调用
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
System.Windows.Forms.MessageBox.Show(ie.LocationURL);
string filename = System.IO.Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
if (filename.Equals("iexplore"))
{
System.Windows.Forms.MessageBox.Show(ie.Document.ToString()); //在未装VS2008的机器上,ie.Document这个属性是System._Object,但是在装了VS2008的机器上ie.Document的属性是mshtml.HTMLDocumentClass
}
}
非常奇怪,请知道的兄弟不吝赐教。