Process 類別

定義

提供對本機和遠端處理序的存取,並讓您能夠啟動和停止本機系統處理序。Provides access to local and remote processes and enables you to start and stop local system processes.

public ref class Process : System::ComponentModel::Component, IDisposable
public ref class Process : IDisposable
public ref class Process : System::ComponentModel::Component
public class Process : System.ComponentModel.Component, IDisposable
public class Process : IDisposable
public class Process : System.ComponentModel.Component
type Process = class
    inherit Component
    interface IDisposable
type Process = class
    interface IDisposable
type Process = class
    inherit Component
Public Class Process
Inherits Component
Implements IDisposable
Public Class Process
Implements IDisposable
Public Class Process
Inherits Component
繼承
繼承
Process
實作

範例

下列範例會使用類別的實例 Process 來啟動處理常式。The following example uses an instance of the Process class to start a process.

#using <System.dll>
using namespace System;
using namespace System::Diagnostics;
using namespace System::ComponentModel;

int main()
{
    Process^ myProcess = gcnew 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
    {
        public static void Main()
        {
            try
            {
                using (Process myProcess = new Process())
                {
                    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);
            }
        }
    }
}
Imports System.Diagnostics
Imports System.ComponentModel

Namespace MyProcessSample
    Class MyProcess
        Public Shared Sub Main()
            Try
                Using myProcess As New Process()

                    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.
                End Using
            Catch e As Exception
                Console.WriteLine((e.Message))
            End Try
        End Sub
    End Class
End Namespace

下列範例會使用 Process 類別本身和靜態 Start 方法來啟動處理常式。The following example uses the Process class itself and a static Start method to start a process.

#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
using namespace System::ComponentModel;

// 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()
{
    // URLs 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 = gcnew ProcessStartInfo("IExplore.exe");
    startInfo->WindowStyle = ProcessWindowStyle::Minimized;
    Process::Start(startInfo);
    startInfo->Arguments = "www.northwindtraders.com";
    Process::Start(startInfo);
}

int main()
{
    // Get the path that stores favorite links.
    String^ myFavoritesPath = Environment::GetFolderPath(Environment::SpecialFolder::Favorites);
    OpenApplication(myFavoritesPath);
    OpenWithArguments();
    OpenWithStartInfo();
}
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();
        }
    }
}
Imports System.Diagnostics
Imports System.ComponentModel

Namespace MyProcessSample
    Class MyProcess
        ' Opens the Internet Explorer application.
        Public Sub OpenApplication(myFavoritesPath As String)
            ' 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)
        End Sub

        ' Opens URLs and .html documents using Internet Explorer.
        Sub OpenWithArguments()
            ' URLs 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")
        End Sub

        ' Uses the ProcessStartInfo class to start new processes,
        ' both in a minimized mode.
        Sub OpenWithStartInfo()
            Dim startInfo As New ProcessStartInfo("IExplore.exe")
            startInfo.WindowStyle = ProcessWindowStyle.Minimized

            Process.Start(startInfo)

            startInfo.Arguments = "www.northwindtraders.com"

            Process.Start(startInfo)
        End Sub

        Shared Sub Main()
            ' Get the path that stores favorite links.
            Dim myFavoritesPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Favorites)

            Dim myProcess As New MyProcess()

            myProcess.OpenApplication(myFavoritesPath)
            myProcess.OpenWithArguments()
            myProcess.OpenWithStartInfo()
        End Sub
    End Class
End Namespace 'MyProcessSample

下列 F # 範例定義一個函式,該函式 runProc 會啟動處理常式、捕捉所有輸出和錯誤資訊,以及記錄進程已執行的毫秒數。The following F# example defines a runProc function that starts a process, captures all output and error information, and records the number of milliseconds that the process has run. runProc函數有三個參數:要啟動的應用程式名稱、要提供給應用程式的引數,以及起始目錄。The runProc function has three parameters: the name of application to launch, the arguments to supply to the application, and the starting directory.

open System
open System.Diagnostics

let runProc filename args startDir : seq<string> * seq<string> = 
    let timer = Stopwatch.StartNew()
    let procStartInfo = 
        ProcessStartInfo(
            RedirectStandardOutput = true,
            RedirectStandardError = true,
            UseShellExecute = false,
            FileName = filename,
            Arguments = args
        )
    match startDir with | Some d -> procStartInfo.WorkingDirectory <- d | _ -> ()

    let outputs = System.Collections.Generic.List<string>()
    let errors = System.Collections.Generic.List<string>()
    let outputHandler f (_sender:obj) (args:DataReceivedEventArgs) = f args.Data
    use p = new Process(StartInfo = procStartInfo)
    p.OutputDataReceived.AddHandler(DataReceivedEventHandler (outputHandler outputs.Add))
    p.ErrorDataReceived.AddHandler(DataReceivedEventHandler (outputHandler errors.Add))
    let started = 
        try
            p.Start()
        with | ex ->
            ex.Data.Add("filename", filename)
            reraise()
    if not started then
        failwithf "Failed to start process %s" filename
    printfn "Started %s with pid %i" p.ProcessName p.Id
    p.BeginOutputReadLine()
    p.BeginErrorReadLine()
    p.WaitForExit()
    timer.Stop()
    printfn "Finished %s after %A milliseconds" filename timer.ElapsedMilliseconds
    let cleanOut l = l |> Seq.filter (fun o -> String.IsNullOrEmpty o |> not)
    cleanOut outputs,cleanOut errors

函式的程式碼是 runProcImaginaryDevelopment 所撰寫,並可在 Microsoft Public 授權下取得。The code for the runProc function was written by ImaginaryDevelopment and is available under the Microsoft Public License.

備註

Process元件可讓您存取在電腦上執行的處理常式。A Process component provides access to a process that is running on a computer. 以最簡單的方式來說,程式是執行中的應用程式。A process, in the simplest terms, is a running app. 執行緒是作業系統配置處理器時間的基本單位。A thread is the basic unit to which the operating system allocates processor time. 執行緒可以執行進程程式碼的任何部分,包括目前由另一個執行緒執行的元件。A thread can execute any part of the code of the process, including parts currently being executed by another thread.

Process元件是啟動、停止、控制和監視應用程式的有用工具。The Process component is a useful tool for starting, stopping, controlling, and monitoring apps. 您可以使用 Process 元件取得正在執行之處理常式的清單,也可以啟動新的進程。You can use the Process component, to obtain a list of the processes that are running, or you can start a new process. Process元件可用來存取系統進程。A Process component is used to access system processes. Process元件初始化之後,就可以用來取得執行中進程的相關資訊。After a Process component has been initialized, it can be used to obtain information about the running process. 這類資訊包括一組執行緒、載入的模組 ( .dll 和 .exe 檔) ,以及效能資訊,例如進程正在使用的記憶體數量。Such information includes the set of threads, the loaded modules (.dll and .exe files), and performance information such as the amount of memory the process is using.

此型別代表 IDisposable 介面。This type implements the IDisposable interface. 當您完成使用型別時,您應該直接或間接處置它。When you have finished using the type, you should dispose of it either directly or indirectly. 若要直接處置型別,請呼叫其 try/finally 區塊中的 Dispose 方法。To dispose of the type directly, call its Dispose method in a try/finally block. 若要間接處置它,請使用語言建構函式,例如 using (在 C# 中) 或 Using (在 Visual Basic 中)。To dispose of it indirectly, use a language construct such as using (in C#) or Using (in Visual Basic). 如需詳細資訊,請參閱 IDisposable 介面文章中的<使用實作 IDisposable 的物件>一節。For more information, see the "Using an Object that Implements IDisposable" section in the IDisposable interface topic.

注意

32位進程無法存取64位進程的模組。32-bit processes cannot access the modules of a 64-bit process. 如果您嘗試從32位進程取得64位進程的相關資訊,您會收到 Win32Exception 例外狀況。If you try to get information about a 64-bit process from a 32-bit process, you will get a Win32Exception exception. 另一方面,64位進程可以存取32位進程的模組。A 64-bit process, on the other hand, can access the modules of a 32-bit process.

流程元件會一次取得一組屬性的相關資訊。The process component obtains information about a group of properties all at once. Process 元件取得任何群組成員的相關資訊之後,它會快取該群組中其他屬性的值,而且在您呼叫方法之前,不會取得群組其他成員的新資訊 RefreshAfter the Process component has obtained information about one member of any group, it will cache the values for the other properties in that group and not obtain new information about the other members of the group until you call the Refresh method. 因此,不保證會比上一次呼叫方法更新的屬性值 RefreshTherefore, a property value is not guaranteed to be any newer than the last call to the Refresh method. 群組明細與作業系統相依。The group breakdowns are operating-system dependent.

如果您在系統中使用引號宣告了路徑變數,您必須在啟動任何在該位置找到的進程時,完整限定該路徑。If you have a path variable declared in your system using quotes, you must fully qualify that path when starting any process found in that location. 否則,系統將找不到路徑。Otherwise, the system will not find the path. 例如,如果 c:\mypath 不在您的路徑中,而且您使用引號來新增它: path = %path%;"c:\mypath" ,則必須在啟動時完整限定中的任何處理程式 c:\mypathFor example, if c:\mypath is not in your path, and you add it using quotation marks: path = %path%;"c:\mypath", you must fully qualify any process in c:\mypath when starting it.

系統進程會依其進程識別碼在系統上唯一識別。A system process is uniquely identified on the system by its process identifier. 就像許多 Windows 資源一樣,進程也會透過其控制碼來識別,這在電腦上可能不是唯一的。Like many Windows resources, a process is also identified by its handle, which might not be unique on the computer. 控制碼是資源識別碼的泛型詞彙。A handle is the generic term for an identifier of a resource. 作業系統會保存進程控制碼,該控制碼會透過元件的屬性來存取 Handle Process ,即使進程已結束也一樣。The operating system persists the process handle, which is accessed through the Handle property of the Process component, even when the process has exited. 因此,您可以取得進程的系統管理資訊,例如, ExitCode (通常是零表示成功或非零的錯誤碼) 和 ExitTimeThus, you can get the process's administrative information, such as the ExitCode (usually either zero for success or a nonzero error code) and the ExitTime. 控制碼是極具價值的資源,因此流失的控制碼比洩漏記憶體更是惡毒。Handles are an extremely valuable resource, so leaking handles is more virulent than leaking memory.

注意

這個類別包含連結要求以及類別層級上套用至所有成員的繼承要求。This class contains a link demand and an inheritance demand at the class level that applies to all members. SecurityException當立即呼叫端或衍生類別沒有完全信任的許可權時,就會擲回。A SecurityException is thrown when either the immediate caller or the derived class does not have full-trust permission. 如需安全性需求的詳細資訊,請參閱 連結要求For details about security demands, see Link Demands.

.NET Core.NET Core 筆記Notes

在 .NET Framework 中, Process 類別預設會使用編碼方式, Console 通常是字碼頁編碼,用於輸入、輸出和錯誤資料流程。In the .NET Framework, the Process class by default uses Console encodings, which are typically code page encodings, for the input, output, and error streams. 例如程式碼,在文化特性是英文 (美國) 的系統上,字碼頁437是類別的預設編碼方式 ConsoleFor example code, on systems whose culture is English (United States), code page 437 is the default encoding for the Console class. 不過, .NET Core.NET Core 可能只會提供這些編碼的有限子集。However, .NET Core.NET Core may make only a limited subset of these encodings available. 如果是這種情況,它會使用 Encoding.UTF8 做為預設的編碼方式。If this is the case, it uses Encoding.UTF8 as the default encoding.

如果 Process 物件相依于特定字碼頁編碼方式,您仍然可以在呼叫任何方法 之前,先 執行下列動作,使其可供使用 ProcessIf a Process object depends on specific code page encodings, you can still make them available by doing the following before you call any Process methods:

  1. 將 System.Text.Encoding.CodePages.dll 元件的參考加入至您的專案。Add a reference to the System.Text.Encoding.CodePages.dll assembly to your project.

  2. EncodingProvider從屬性取得物件 CodePagesEncodingProvider.InstanceRetrieve the EncodingProvider object from the CodePagesEncodingProvider.Instance property.

  3. EncodingProvider 物件傳遞給 Encoding.RegisterProvider 方法,以提供編碼提供者所支援的其他編碼。Pass the EncodingProvider object to the Encoding.RegisterProvider method to make the additional encodings supported by the encoding provider available.

Process如果您已在呼叫任何方法之前註冊編碼提供者,則類別會自動使用預設系統編碼,而不是 UTF8 ProcessThe Process class will then automatically use the default system encoding rather than UTF8, provided that you have registered the encoding provider before calling any Process methods.

建構函式

Process()

初始化 Process 類別的新執行個體。Initializes a new instance of the Process class.

屬性

BasePriority

取得相關處理序的基礎優先權 (Base Priority)。Gets the base priority of the associated process.

CanRaiseEvents

取得值,指出元件是否能引發事件。Gets a value indicating whether the component can raise an event.

(繼承來源 Component)
Container

取得包含 IContainerComponentGets the IContainer that contains the Component.

(繼承來源 Component)
DesignMode

取得值,指出 Component 目前是否處於設計模式。Gets a value that indicates whether the Component is currently in design mode.

(繼承來源 Component)
EnableRaisingEvents

取得或設定是否應該在處理序終止時引發 Exited 事件。Gets or sets whether the Exited event should be raised when the process terminates.

Events

取得附加在這個 Component 上的事件處理常式清單。Gets the list of event handlers that are attached to this Component.

(繼承來源 Component)
ExitCode

取得相關處理序終止時指定的值。Gets the value that the associated process specified when it terminated.

ExitTime

取得相關的處理序結束的時間。Gets the time that the associated process exited.

Handle

取得相關處理序的原生控制代碼。Gets the native handle of the associated process.

HandleCount

取得處理序開啟的控制代碼數目。Gets the number of handles opened by the process.

HasExited

取得值,指出相關的處理序是否已經終止。Gets a value indicating whether the associated process has been terminated.

Id

取得相關處理序的唯一識別項。Gets the unique identifier for the associated process.

MachineName

取得相關處理序正在執行的所在電腦的名稱。Gets the name of the computer the associated process is running on.

MainModule

取得相關處理序的主要模組。Gets the main module for the associated process.

MainWindowHandle

取得相關處理序主視窗的視窗控制代碼。Gets the window handle of the main window of the associated process.

MainWindowTitle

取得處理序的主視窗標題。Gets the caption of the main window of the process.

MaxWorkingSet

取得或設定關聯的處理序所允許的工作集大小上限,以位元組為單位。Gets or sets the maximum allowable working set size, in bytes, for the associated process.

MinWorkingSet

取得或設定關聯的處理序所允許的工作集大小下限,以位元組為單位。Gets or sets the minimum allowable working set size, in bytes, for the associated process.

Modules

取得相關的處理序所載入的模組。Gets the modules that have been loaded by the associated process.

NonpagedSystemMemorySize
已過時。
已過時。
已過時。

取得配置給關聯處理序的未分頁系統記憶體量 (以位元組為單位)。Gets the amount of nonpaged system memory, in bytes, allocated for the associated process.

NonpagedSystemMemorySize64

取得配置給關聯處理序的未分頁系統記憶體量 (以位元組為單位)。Gets the amount of nonpaged system memory, in bytes, allocated for the associated process.

PagedMemorySize
已過時。
已過時。
已過時。

取得配置給關聯處理序的分頁記憶體量 (以位元組為單位)。Gets the amount of paged memory, in bytes, allocated for the associated process.

PagedMemorySize64

取得配置給關聯處理序的分頁記憶體量 (以位元組為單位)。Gets the amount of paged memory, in bytes, allocated for the associated process.

PagedSystemMemorySize
已過時。
已過時。
已過時。

取得配置給關聯處理序的可分頁系統記憶體量 (以位元組為單位)。Gets the amount of pageable system memory, in bytes, allocated for the associated process.

PagedSystemMemorySize64

取得配置給關聯處理序的可分頁系統記憶體量 (以位元組為單位)。Gets the amount of pageable system memory, in bytes, allocated for the associated process.

PeakPagedMemorySize
已過時。
已過時。
已過時。

取得關聯處理序所使用之虛擬記憶體分頁檔的最大記憶體量 (以位元組為單位)。Gets the maximum amount of memory in the virtual memory paging file, in bytes, used by the associated process.

PeakPagedMemorySize64

取得關聯處理序所使用之虛擬記憶體分頁檔的最大記憶體量 (以位元組為單位)。Gets the maximum amount of memory in the virtual memory paging file, in bytes, used by the associated process.

PeakVirtualMemorySize
已過時。
已過時。
已過時。

取得關聯處理序所使用最大虛擬記憶體量 (以位元組為單位)。Gets the maximum amount of virtual memory, in bytes, used by the associated process.

PeakVirtualMemorySize64

取得關聯處理序所使用最大虛擬記憶體量 (以位元組為單位)。Gets the maximum amount of virtual memory, in bytes, used by the associated process.

PeakWorkingSet
已過時。
已過時。
已過時。

取得相關處理序工作集大小的最大值 (位元組)。Gets the peak working set size for the associated process, in bytes.

PeakWorkingSet64

取得關聯處理序所使用最大實體記憶體量 (以位元組為單位)。Gets the maximum amount of physical memory, in bytes, used by the associated process.

PriorityBoostEnabled

取得或設定值,指出作業系統是否應該在主視窗有焦點 (Focus) 時,暫時提高相關的處理序優先權。Gets or sets a value indicating whether the associated process priority should temporarily be boosted by the operating system when the main window has the focus.

PriorityClass

取得或設定相關處理序的整體優先權分類。Gets or sets the overall priority category for the associated process.

PrivateMemorySize
已過時。
已過時。
已過時。

取得配置給關聯處理序的私用記憶體量 (以位元組為單位)。Gets the amount of private memory, in bytes, allocated for the associated process.

PrivateMemorySize64

取得配置給關聯處理序的私用記憶體量 (以位元組為單位)。Gets the amount of private memory, in bytes, allocated for the associated process.

PrivilegedProcessorTime

取得這個處理序使用處理器的授權時間。Gets the privileged processor time for this process.

ProcessName

取得處理序的名稱。Gets the name of the process.

ProcessorAffinity

取得或設定處理器,這個處理序中的執行緒可以在其上排程執行。Gets or sets the processors on which the threads in this process can be scheduled to run.

Responding

取得值,指出處理序的使用者介面是否正在回應。Gets a value indicating whether the user interface of the process is responding.

SafeHandle

取得這個處理序的原生控制代碼。Gets the native handle to this process.

SessionId

取得相關處理序的終端機服務工作階段識別項。Gets the Terminal Services session identifier for the associated process.

Site

取得或設定 ComponentISiteGets or sets the ISite of the Component.

(繼承來源 Component)
StandardError

取得用來讀取應用程式錯誤輸出的資料流。Gets a stream used to read the error output of the application.

StandardInput

取得用來寫入應用程式輸入的資料流。Gets a stream used to write the input of the application.

StandardOutput

取得用來讀取應用程式文字輸出的資料流。Gets a stream used to read the textual output of the application.

StartInfo

取得或設定要傳遞給 ProcessStart() 方法的屬性。Gets or sets the properties to pass to the Start() method of the Process.

StartTime

取得相關的處理序啟動的時間。Gets the time that the associated process was started.

SynchronizingObject

取得或設定物件,用以封送處理因處理序結束事件而發出的事件處理常式呼叫。Gets or sets the object used to marshal the event handler calls that are issued as a result of a process exit event.

Threads

取得正在相關的處理序中執行的執行緒集。Gets the set of threads that are running in the associated process.

TotalProcessorTime

取得這個處理序的總處理器時間。Gets the total processor time for this process.

UserProcessorTime

取得這個處理序的使用者處理器時間。Gets the user processor time for this process.

VirtualMemorySize
已過時。
已過時。
已過時。

取得處理序的虛擬記憶體的大小 (以位元組為單位)。Gets the size of the process's virtual memory, in bytes.

VirtualMemorySize64

取得配置給關聯處理序的虛擬記憶體量,以位元組為單位。Gets the amount of the virtual memory, in bytes, allocated for the associated process.

WorkingSet
已過時。
已過時。
已過時。

取得相關處理序的實體記憶體使用量 (以位元組為單位)。Gets the associated process's physical memory usage, in bytes.

WorkingSet64

取得配置給關聯處理序的實體記憶體量,以位元組為單位。Gets the amount of physical memory, in bytes, allocated for the associated process.

方法

BeginErrorReadLine()

在應用程式的重新導向 StandardError 資料流上開始非同步讀取作業。Begins asynchronous read operations on the redirected StandardError stream of the application.

BeginOutputReadLine()

在應用程式的重新導向 StandardOutput 資料流上開始非同步讀取作業。Begins asynchronous read operations on the redirected StandardOutput stream of the application.

CancelErrorRead()

在應用程式的重新導向 StandardError 資料流上取消非同步讀取作業。Cancels the asynchronous read operation on the redirected StandardError stream of an application.

CancelOutputRead()

在應用程式的重新導向 StandardOutput 資料流上取消非同步讀取作業。Cancels the asynchronous read operation on the redirected StandardOutput stream of an application.

Close()

釋放與這個元件相關的所有資源。Frees all the resources that are associated with this component.

CloseMainWindow()

關閉有使用者介面的處理序,方法是傳送關閉訊息至其主視窗。Closes a process that has a user interface by sending a close message to its main window.

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(繼承來源 MarshalByRefObject)
Dispose()

執行與釋放 (Free)、釋放 (Release) 或重設 Unmanaged 資源相關聯之應用程式定義的工作。Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Dispose()

釋放 Component 所使用的所有資源。Releases all resources used by the Component.

(繼承來源 Component)
Dispose(Boolean)

釋放這個處理序使用的所有資源。Release all resources used by this process.

EnterDebugMode()

啟用目前執行緒上的原生屬性 SeDebugPrivilege,將 Process 元件置於某種狀態,以便與使用特殊模式執行的作業系統處理序互動。Puts a Process component in state to interact with operating system processes that run in a special mode by enabling the native property SeDebugPrivilege on the current thread.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetCurrentProcess()

取得新的 Process 元件,並將其與目前現用處理序相關聯。Gets a new Process component and associates it with the currently active process.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetLifetimeService()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(繼承來源 MarshalByRefObject)
GetProcessById(Int32)

傳回新的 Process 元件,需指定本機電腦上的處理序識別項。Returns a new Process component, given the identifier of a process on the local computer.

GetProcessById(Int32, String)

傳回新的 Process 元件,需指定網路上電腦的處理序識別項和名稱。Returns a new Process component, given a process identifier and the name of a computer on the network.

GetProcesses()

為本機電腦上的每個處理序資源建立新的 Process 元件。Creates a new Process component for each process resource on the local computer.

GetProcesses(String)

為指定電腦上的每個處理序資源建立新的 Process 元件。Creates a new Process component for each process resource on the specified computer.

GetProcessesByName(String)

建立新 Process 元件的陣列,並將其與本機電腦上共用指定處理序名稱的所有處理序資源相關聯。Creates an array of new Process components and associates them with all the process resources on the local computer that share the specified process name.

GetProcessesByName(String, String)

建立新 Process 元件的陣列,並將其與遠端電腦上共用指定處理序名稱的所有處理序資源相關聯。Creates an array of new Process components and associates them with all the process resources on a remote computer that share the specified process name.

GetService(Type)

傳回表示 Component 或其 Container 所提供之服務的物件。Returns an object that represents a service provided by the Component or by its Container.

(繼承來源 Component)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
InitializeLifetimeService()

取得存留期服務物件,以控制這個執行個體的存留期原則。Obtains a lifetime service object to control the lifetime policy for this instance.

(繼承來源 MarshalByRefObject)
Kill()

立即停止相關的處理序。Immediately stops the associated process.

Kill(Boolean)

立即停止關聯的處理序,並選擇性地停止其子處理序。Immediately stops the associated process, and optionally its child/descendent processes.

LeaveDebugMode()

Process 元件離開可與使用特殊模式執行的作業系統處理序互動的狀態。Takes a Process component out of the state that lets it interact with operating system processes that run in a special mode.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。Creates a shallow copy of the current MarshalByRefObject object.

(繼承來源 MarshalByRefObject)
OnExited()

引發 Exited 事件。Raises the Exited event.

Refresh()

捨棄快取於處理序元件內之相關處理序的任何資訊。Discards any information about the associated process that has been cached inside the process component.

Start()

啟動 (或重複使用) 這個 Process 元件的 StartInfo 屬性指定的處理序資源,並將其與元件相關聯。Starts (or reuses) the process resource that is specified by the StartInfo property of this Process component and associates it with the component.

Start(ProcessStartInfo)

啟動含有處理序啟動資訊 (例如,要啟動之處理序的檔名) 的參數所指定的處理序資源,並將該資源與新的 Process 元件相關聯。Starts the process resource that is specified by the parameter containing process start information (for example, the file name of the process to start) and associates the resource with a new Process component.

Start(String)

藉由指定文件或應用程式檔案的名稱啟動處理序資源,並將該資源與新的 Process 元件相關聯。Starts a process resource by specifying the name of a document or application file and associates the resource with a new Process component.

Start(String, IEnumerable<String>)

藉由指定應用程式的名稱和一組命令列引數來啟動處理序資源。Starts a process resource by specifying the name of an application and a set of command line arguments.

Start(String, String)

藉由指定應用程式的名稱和一組命令列引數來啟動處理序資源,並將該資源與新的 Process 元件相關聯。Starts a process resource by specifying the name of an application and a set of command-line arguments, and associates the resource with a new Process component.

Start(String, String, SecureString, String)

藉由指定應用程式的名稱、使用者名稱、密碼和網域來啟動處理序資源,並將該資源與新的 Process 元件相關聯。Starts a process resource by specifying the name of an application, a user name, a password, and a domain and associates the resource with a new Process component.

Start(String, String, String, SecureString, String)

藉由指定應用程式的名稱、一組命令列引數、使用者名稱、密碼和網域來啟動處理序資源,並將該資源與新的 Process 元件相關聯。Starts a process resource by specifying the name of an application, a set of command-line arguments, a user name, a password, and a domain and associates the resource with a new Process component.

ToString()

將處理序的名稱格式化為字串,如果適用,將它和父代 (Parent) 元件類型結合。Formats the process's name as a string, combined with the parent component type, if applicable.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)
WaitForExit()

指示 Process 元件無限期等候相關聯處理序結束。Instructs the Process component to wait indefinitely for the associated process to exit.

WaitForExit(Int32)

指示 Process 元件等候相關聯處理序結束的指定毫秒數。Instructs the Process component to wait the specified number of milliseconds for the associated process to exit.

WaitForExitAsync(CancellationToken)

指示處理序元件等候相關聯的處理序結束,或等候 cancellationToken 取消。Instructs the process component to wait for the associated process to exit, or for the cancellationToken to be cancelled.

WaitForInputIdle()

Process 元件無限期等候相關聯處理序進入閒置狀態。Causes the Process component to wait indefinitely for the associated process to enter an idle state. 這個多載只適用於具有使用者介面和訊息迴圈的處理序。This overload applies only to processes with a user interface and, therefore, a message loop.

WaitForInputIdle(Int32)

Process 元件等候相關聯處理序進入閒置狀態的指定毫秒數。Causes the Process component to wait the specified number of milliseconds for the associated process to enter an idle state. 這個多載只適用於具有使用者介面和訊息迴圈的處理序。This overload applies only to processes with a user interface and, therefore, a message loop.

事件

Disposed

Dispose() 方法的呼叫處置元件時,就會發生。Occurs when the component is disposed by a call to the Dispose() method.

(繼承來源 Component)
ErrorDataReceived

發生於應用程式寫入至其重新導向的 StandardError 資料流時。Occurs when an application writes to its redirected StandardError stream.

Exited

發生於處理序結束時。Occurs when a process exits.

OutputDataReceived

發生於應用程式將某行寫入至其重新導向的 StandardOutput 資料流時。Occurs each time an application writes a line to its redirected StandardOutput stream.

適用於

另請參閱