共用方式為


ProcessModule 類別

定義

代表載入到特定程序的 .dll 或 .exe 檔案。

public ref class ProcessModule : System::ComponentModel::Component
public ref class ProcessModule
public class ProcessModule : System.ComponentModel.Component
public class ProcessModule
type ProcessModule = class
    inherit Component
type ProcessModule = class
Public Class ProcessModule
Inherits Component
Public Class ProcessModule
繼承
繼承
ProcessModule

範例

下列程式碼範例示範如何使用 ProcessModule 類別來取得並顯示有關 Notepad.exe 應用程式所使用之所有模組的資訊。

Process^ myProcess = gcnew Process;

// Get the process start information of notepad.
ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" );

// Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' Object*.
myProcess->StartInfo = myProcessStartInfo;

// Create a notepad.
myProcess->Start();
System::Threading::Thread::Sleep( 1000 );
ProcessModule^ myProcessModule;

// Get all the modules associated with 'myProcess'.
ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules;
Console::WriteLine( "Properties of the modules  associated with 'notepad' are:" );

// Display the properties of each of the modules.
for ( int i = 0; i < myProcessModuleCollection->Count; i++ )
{
   myProcessModule = myProcessModuleCollection[ i ];
   Console::WriteLine( "The moduleName is {0}", myProcessModule->ModuleName );
   Console::WriteLine( "The {0}'s base address is: {1}", myProcessModule->ModuleName, myProcessModule->BaseAddress );
   Console::WriteLine( "The {0}'s Entry point address is: {1}", myProcessModule->ModuleName, myProcessModule->EntryPointAddress );
   Console::WriteLine( "The {0}'s File name is: {1}", myProcessModule->ModuleName, myProcessModule->FileName );
}
myProcessModule = myProcess->MainModule;

// Display the properties of the main module.
Console::WriteLine( "The process's main moduleName is: {0}", myProcessModule->ModuleName );
Console::WriteLine( "The process's main module's base address is: {0}", myProcessModule->BaseAddress );
Console::WriteLine( "The process's main module's Entry point address is: {0}", myProcessModule->EntryPointAddress );
Console::WriteLine( "The process's main module's File name is: {0}", myProcessModule->FileName );
myProcess->CloseMainWindow();
using (Process myProcess = new Process())
{
    // Get the process start information of notepad.
    ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("notepad.exe");
    // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' object.
    myProcess.StartInfo = myProcessStartInfo;
    // Create a notepad.
    myProcess.Start();
    System.Threading.Thread.Sleep(1000);
    ProcessModule myProcessModule;
    // Get all the modules associated with 'myProcess'.
    ProcessModuleCollection myProcessModuleCollection = myProcess.Modules;
    Console.WriteLine("Properties of the modules  associated "
        + "with 'notepad' are:");
    // Display the properties of each of the modules.
    for (int i = 0; i < myProcessModuleCollection.Count; i++)
    {
        myProcessModule = myProcessModuleCollection[i];
        Console.WriteLine("The moduleName is "
            + myProcessModule.ModuleName);
        Console.WriteLine("The " + myProcessModule.ModuleName + "'s base address is: "
            + myProcessModule.BaseAddress);
        Console.WriteLine("The " + myProcessModule.ModuleName + "'s Entry point address is: "
            + myProcessModule.EntryPointAddress);
        Console.WriteLine("The " + myProcessModule.ModuleName + "'s File name is: "
            + myProcessModule.FileName);
    }
    // Get the main module associated with 'myProcess'.
    myProcessModule = myProcess.MainModule;
    // Display the properties of the main module.
    Console.WriteLine("The process's main moduleName is:  "
        + myProcessModule.ModuleName);
    Console.WriteLine("The process's main module's base address is: "
        + myProcessModule.BaseAddress);
    Console.WriteLine("The process's main module's Entry point address is: "
        + myProcessModule.EntryPointAddress);
    Console.WriteLine("The process's main module's File name is: "
        + myProcessModule.FileName);
    myProcess.CloseMainWindow();
}
Using myProcess As New Process()
    ' Get the process start information of notepad.
    Dim myProcessStartInfo As New ProcessStartInfo("notepad.exe")
    ' Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' object.
    myProcess.StartInfo = myProcessStartInfo
    ' Create a notepad.
    myProcess.Start()
    System.Threading.Thread.Sleep(1000)
    Dim myProcessModule As ProcessModule
    ' Get all the modules associated with 'myProcess'.
    Dim myProcessModuleCollection As ProcessModuleCollection = myProcess.Modules
    Console.WriteLine("Properties of the modules  associated with 'notepad' are:")
    ' Display the properties of each of the modules.
    Dim i As Integer
    For i = 0 To myProcessModuleCollection.Count - 1
        myProcessModule = myProcessModuleCollection(i)
        Console.WriteLine("The moduleName is " + myProcessModule.ModuleName)
        Console.WriteLine("The " + myProcessModule.ModuleName.ToString() +
                   "'s base address is: " + myProcessModule.BaseAddress.ToString())
        Console.WriteLine("The " + myProcessModule.ModuleName.ToString() +
                "'s Entry point address is: " + myProcessModule.EntryPointAddress.ToString())
        Console.WriteLine("The " + myProcessModule.ModuleName +
                                "'s File name is: " + myProcessModule.FileName)
    Next i
    ' Get the main module associated with 'myProcess'.
    myProcessModule = myProcess.MainModule
    ' Display the properties of the main module.
    Console.WriteLine("The process's main moduleName is:  " + myProcessModule.ModuleName)
    Console.WriteLine("The process's main module's base address is: " +
                            myProcessModule.BaseAddress.ToString())
    Console.WriteLine("The process's main module's Entry point address is: " +
                            myProcessModule.EntryPointAddress.ToString())
    Console.WriteLine("The process's main module's File name is: " +
                            myProcessModule.FileName)
    myProcess.CloseMainWindow()
End Using

備註

模組是可執行檔或動態連結程式庫 (DLL)。 每個處理序都是由一或多個模組組成的。 您可以使用此類別來取得有關模組的資訊。

重要

此型別代表 IDisposable 介面。 當您完成使用型別時,您應該直接或間接處置它。 若要直接處置型別,請呼叫其 try/catch 區塊中的 Dispose 方法。 若要間接處置它,請使用語言建構函式,例如 using (在 C# 中) 或 Using (在 Visual Basic 中)。 如需詳細資訊,請參閱 IDisposable 介面文章中的<使用實作 IDisposable 的物件>一節。

屬性

BaseAddress

取得模組載入處的記憶體位址。

CanRaiseEvents

取得值,指出元件是否能引發事件。

(繼承來源 Component)
Container

取得包含 IContainerComponent

(繼承來源 Component)
DesignMode

取得值,指出 Component 目前是否處於設計模式。

(繼承來源 Component)
EntryPointAddress

取得當系統載入並執行模組時執行之函式的記憶體位址。

Events

取得附加在這個 Component 上的事件處理常式清單。

(繼承來源 Component)
FileName

取得模組的完整路徑。

FileVersionInfo

取得模組的版本資訊。

ModuleMemorySize

取得載入模組所需的記憶體數量。

ModuleName

取得處理序模組的名稱。

Site

取得或設定 ComponentISite

(繼承來源 Component)

方法

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。

(繼承來源 MarshalByRefObject)
Dispose()

釋放 Component 所使用的所有資源。

(繼承來源 Component)
Dispose(Boolean)

釋放 Component 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 Component)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetLifetimeService()
已淘汰.

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。

(繼承來源 MarshalByRefObject)
GetService(Type)

傳回表示 Component 或其 Container 所提供之服務的物件。

(繼承來源 Component)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
InitializeLifetimeService()
已淘汰.

取得存留期服務物件,以控制這個執行個體的存留期原則。

(繼承來源 MarshalByRefObject)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。

(繼承來源 MarshalByRefObject)
ToString()

將模組的名稱轉換為字串。

事件

Disposed

Dispose() 方法的呼叫處置元件時,就會發生。

(繼承來源 Component)

適用於