100分求大神帮助
System.Diagnostics.Process.Start(RichTextBox6.Text) '测试按钮
这个是在新窗口打开URL 有可以在原窗口打开的代码么(就是在当前活动的IE窗口内打开URL的代码) 请大神们帮帮忙 尽量详细点
[解决办法]
引用Interop.SHDocVw.dll
using System;
using System.IO;
using System.Windows.Forms;
namespace WindowsFormsApplication7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void OpenUrl(string url)
{
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
string filename = Path.GetFileName(ie.FullName).ToLower();
if (filename.Equals("iexplore.exe"))
{
object o = null;
ie.Navigate(url, ref o, ref o, ref o, ref o);
return;
}
}
System.Diagnostics.Process.Start(url);
}
private void button1_Click(object sender, EventArgs e)
{
OpenUrl("http://www.google.com");
}
}
}
Private Sub OpenUrl(ByVal url As String)
Dim shellWindows As SHDocVw.ShellWindows = New SHDocVw.ShellWindows()
For Each ie As SHDocVw.InternetExplorer In shellWindows
Dim filename As String = Path.GetFileName(ie.FullName).ToLower()
If filename.Equals("iexplore.exe") Then
Dim o As Object = Nothing
ie.Navigage(url, o, o, o, o)
Return
End If
Next
System.Diagnostics.Process.Start(url)
End Sub