使用c#在IE中打开一个网页

如何在单击ac#application中的按钮时在IE中打开网页。 我的目的是为ac#应用程序创建一个Web登录,需要在IE中以指定的宽度和高度打开,并且需要在应用程序中调用一个函数。

来自http://msdn.microsoft.com/en-us/library/system.diagnostics.process(VS.71).aspx

using System; using System.Diagnostics; using System.ComponentModel; namespace MyProcessSample { ///  /// Shell for the sample. ///  public class MyProcess { ///  /// Opens the Internet Explorer application. ///  public void OpenApplication(string myFavoritesPath) { // Start Internet Explorer. Defaults to the home page. Process.Start("IExplore.exe"); // Display the contents of the favorites folder in the browser. Process.Start(myFavoritesPath); } ///  /// Opens urls and .html documents using Internet Explorer. ///  public void OpenWithArguments() { // url's are not considered documents. They can only be opened // by passing them as arguments. Process.Start("IExplore.exe", "www.northwindtraders.com"); // Start a Web page using a browser associated with .html and .asp files. Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm"); Process.Start("IExplore.exe", "C:\\myPath\\myFile.asp"); } ///  /// Uses the ProcessStartInfo class to start new processes, both in a minimized /// mode. ///  public void OpenWithStartInfo() { ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe"); startInfo.WindowStyle = ProcessWindowStyle.Minimized; Process.Start(startInfo); startInfo.Arguments = "www.northwindtraders.com"; Process.Start(startInfo); } public static void Main() { // Get the path that stores favorite links. string myFavoritesPath = Environment.GetFolderPath(Environment.SpecialFolder.Favorites); MyProcess myProcess = new MyProcess(); myProcess.OpenApplication(myFavoritesPath); myProcess.OpenWithArguments(); myProcess.OpenWithStartInfo(); } } } 
 System.Diagnostics.Process.Start("iexplore", "http://example.com"); 

有一种方法可以在默认浏览器System.Diagnostics.Process.Start(url);打开页面System.Diagnostics.Process.Start(url);

如果你想专门在IE中打开它,你可能需要创建一个以URL作为参数的新IE进程。

UPD:如果要运行函数,请将GET参数插入到url字符串中(即http://stackoverflow.com/page?runFunction=1 )并在应用程序代码中检查runFunction参数并根据其值决定是否您的应用程序需要运行该function。

我不认为可以指定新的IE窗口宽度和高度值,您可能需要使用javascript。