相关疑难解决方法(0)

C#如何从IE获取当前URL?

我想从IE(.NET 4)获取当前的URL.为此,我添加了对Microsoft Interner Controls的引用并添加了代码(来自http://omegacoder.com/?p=63)

foreach (InternetExplorer ie in new ShellWindowsClass())
{
   textBox1.Text = ie.LocationURL.ToString();
}
Run Code Online (Sandbox Code Playgroud)

但我得到2个错误:

1] The type 'SHDocVw.ShellWindowsClass' has no constructors defined

2] Interop type 'SHDocVw.ShellWindowsClass' cannot be embedded.
   Use the applicable interface instead.
Run Code Online (Sandbox Code Playgroud)

怎么解决?

c# internet-explorer

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×1

internet-explorer ×1