System.Diagnostics
函数原型:
public static Process Start ( string fileName, string arguments )举例:
//调用IE浏览器 System.Diagnostics.Process.Start("iexplore.exe", "https://www.google.com.hk/?gws_rd=cr");
函数原型:
public static Process Start( string fileName )
举例:
//调用系统默认的浏览器 System.Diagnostics.Process.Start("https://www.google.com.hk/?gws_rd=cr");
using System; using System.Diagnostics; using System.ComponentModel; namespace MyProcessSample { class MyProcess { public static void Main() { Process myProcess = new Process(); try { myProcess.StartInfo.UseShellExecute = false; // You can start any process, HelloWorld is a do-nothing example. myProcess.StartInfo.FileName = "C:\\HelloWorld.exe"; myProcess.StartInfo.CreateNoWindow = true; myProcess.Start(); // This code assumes the process you are starting will terminate itself. // Given that is is started without a window so you cannot terminate it // on the desktop, it must terminate itself or you can do it programmatically // from this application using the Kill method. } catch (Exception e) { Console.WriteLine(e.Message); } } } }
using System; using System.Diagnostics; using System.ComponentModel; namespace MyProcessSample { class MyProcess { // Opens the Internet Explorer application. 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. 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. void OpenWithStartInfo() { ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe"); startInfo.WindowStyle = ProcessWindowStyle.Minimized; Process.Start(startInfo); startInfo.Arguments = "www.northwindtraders.com"; Process.Start(startInfo); } 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(); } } }参考文档: 有个地方叫msdn