我找了一下,好像关键字还不好找,麻烦告诉一下,谢谢!

解决方案 »

  1.   

    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:\\myPath\\myFile.htm");
                Process.Start("IExplore.exe", "C:\\myPath\\myFile.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();               }    
        }
    }
      

  2.   

    下面的示例使用 Process 类的实例启动进程。[Visual Basic] 
    Imports System
    Imports System.Diagnostics
    Imports System.ComponentModel
    Namespace MyProcessSample
        _
       '/ <summary>
       '/ Shell for the sample.
       '/ </summary>
       Public Class MyProcess
          ' These are the Win32 error code for file not found or access denied.
          Private ERROR_FILE_NOT_FOUND As Integer = 2
          Private ERROR_ACCESS_DENIED As Integer = 5
          
          
          '/ <summary>
          '/ Prints a file with a .doc extension.
          '/ </summary>
          Public Sub PrintDoc()
             Dim myProcess As New Process()
             
             Try
                ' Get the path that stores user documents.
                Dim myDocumentsPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
                
                myProcess.StartInfo.FileName = myDocumentsPath + "\MyFile.doc"
                myProcess.StartInfo.Verb = "Print"
                myProcess.StartInfo.CreateNoWindow = True
                myProcess.Start()
             Catch e As Win32Exception
                If e.NativeErrorCode = ERROR_FILE_NOT_FOUND Then
                   Console.WriteLine((e.Message + ". Check the path."))
                
                Else
                   If e.NativeErrorCode = ERROR_ACCESS_DENIED Then
                      ' Note that if your word processor might generate exceptions
                      ' such as this, which are handled first.
                      Console.WriteLine((e.Message + ". You do not have permission to print this file."))
                   End If
                End If
             End Try
          End Sub 'PrintDoc
          
          
          Public Shared Sub Main()
             Dim myProcess As New MyProcess()
             myProcess.PrintDoc()
          End Sub 'Main
       End Class 'MyProcess
    End Namespace 'MyProcessSample[C#] 
    using System;
    using System.Diagnostics;
    using System.ComponentModel;namespace MyProcessSample
    {
        /// <summary>
        /// Shell for the sample.
        /// </summary>
        public class MyProcess
        {
            // These are the Win32 error code for file not found or access denied.
            const int ERROR_FILE_NOT_FOUND =2;
            const int ERROR_ACCESS_DENIED = 5;        /// <summary>
            /// Prints a file with a .doc extension.
            /// </summary>
            public void PrintDoc()
            {
                Process myProcess = new Process();
                
                try
                {
                    // Get the path that stores user documents.
                    string myDocumentsPath = 
                        Environment.GetFolderPath(Environment.SpecialFolder.Personal);                myProcess.StartInfo.FileName = myDocumentsPath + "\\MyFile.doc"; 
                    myProcess.StartInfo.Verb = "Print";
                    myProcess.StartInfo.CreateNoWindow = true;
                    myProcess.Start();
                }
                catch (Win32Exception e)
                {
                    if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
                    {
                        Console.WriteLine(e.Message + ". Check the path.");
                    }                 else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
                    {
                        // Note that if your word processor might generate exceptions
                        // such as this, which are handled first.
                        Console.WriteLine(e.Message + 
                            ". You do not have permission to print this file.");
                    }
                }
            }
            public static void Main()
            {
                MyProcess myProcess = new MyProcess();
                myProcess.PrintDoc();
            }
        }
    }
      

  3.   

    如果要启动notepad.exe
    见下,具体参数可以自已设一下.ProcessStartInfo startInfo = new ProcessStartInfo("notepad.exe");
    startInfo.WindowStyle = ProcessWindowStyle.Minimized;Process.Start(startInfo);startInfo.Arguments = "www.northwindtraders.com";Process.Start(startInfo);
      

  4.   

    直接在按钮事件写上
    System.Diagnostics.Process.Start("notepad.exe")就能打开记事本了~!
      

  5.   

    可以查阅msdn的.net演练,好像是胖客户端应用程序的例子,里面就有了!