在IE中打开一个网页使用c#
发布时间:2020-12-14 21:39:38 所属栏目:资源 来源:网络整理
导读:如何在IE中打开网页,同时点击c#应用程序中的按钮。 我的目的是创建一个需要在IE中以指定的宽度和高度打开的c#应用程序的Web登录,并且需要在应用程序中调用一个函数。 解决方法 从 http://msdn.microsoft.com/en-us/library/system.diagnostics.process(VS.
如何在IE中打开网页,同时点击c#应用程序中的按钮。
我的目的是创建一个需要在IE中以指定的宽度和高度打开的c#应用程序的Web登录,并且需要在应用程序中调用一个函数。 解决方法
从
http://msdn.microsoft.com/en-us/library/system.diagnostics.process(VS.71).aspx
using System; using System.Diagnostics; using System.ComponentModel; namespace MyProcessSample { /// <summary> /// Shell for the sample. /// </summary> public class MyProcess { /// <summary> /// Opens the Internet Explorer application. /// </summary> 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); } /// <summary> /// Opens urls and .html documents using Internet Explorer. /// </summary> 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:myPathmyFile.htm"); Process.Start("IExplore.exe","C:myPathmyFile.asp"); } /// <summary> /// Uses the ProcessStartInfo class to start new processes,both in a minimized /// mode. /// </summary> 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(); } } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |