ProcessModule 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
代表載入到特定程序的 .dll 或 .exe 檔案。
public ref class ProcessModule : System::ComponentModel::Component
public class ProcessModule : System.ComponentModel.Component
type ProcessModule = class
inherit Component
Public Class ProcessModule
Inherits Component
- 繼承
範例
以下程式碼範例示範如何利用該 ProcessModule 類別取得並顯示 Notepad.exe 應用程式所使用的所有模組資訊。
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)。 每個流程由一個或多個模組組成。 你可以利用這門課來獲取模組的相關資訊。
Important
此類型會實作 IDisposable 介面。 當您完成使用這個物品後,應直接或間接地處理它。 若要直接處置類型,請在 Disposetry/ 區塊中呼叫其 catch 方法。 若要間接處置它,請使用語言建構,例如 using (C#) 或 Using (在 Visual Basic 中)。 如需詳細資訊,請參閱介面主題中的
屬性
| 名稱 | Description |
|---|---|
| BaseAddress |
取得模組載入的記憶體位址。 |
| CanRaiseEvents |
會得到一個值,表示該元件是否能引發事件。 (繼承來源 Component) |
| Container |
得到 IContainer 包含 Component的 。 (繼承來源 Component) |
| DesignMode |
會得到一個值,表示目前 Component 是否處於設計模式。 (繼承來源 Component) |
| EntryPointAddress |
取得系統載入並執行模組時執行的函式記憶體位址。 |
| Events |
會取得與此 Component連結的事件處理程序清單。 (繼承來源 Component) |
| FileName |
能取得完整的模組路徑。 |
| FileVersionInfo |
取得模組的版本資訊。 |
| ModuleMemorySize |
讀取載入模組所需的記憶體容量。 |
| ModuleName |
會得到程序模組的名稱。 |
| Site | (繼承來源 Component) |
方法
| 名稱 | Description |
|---|---|
| CreateObjRef(Type) |
建立一個物件,包含產生代理伺服器所需的所有相關資訊,用於與遠端物件通訊。 (繼承來源 MarshalByRefObject) |
| Dispose() |
釋放所有由 Component. (繼承來源 Component) |
| Dispose(Boolean) |
釋放 未管理的資源, Component 並可選擇性地釋放受管理資源。 (繼承來源 Component) |
| Equals(Object) |
判斷指定的 物件是否等於目前的物件。 (繼承來源 Object) |
| GetHashCode() |
做為預設雜湊函式。 (繼承來源 Object) |
| GetLifetimeService() |
取得目前控制此實例生命週期政策的終身服務物件。 (繼承來源 MarshalByRefObject) |
| GetService(Type) |
回傳一個由 或Component其 所提供的Container服務的物件。 (繼承來源 Component) |
| GetType() |
取得目前實例的 Type。 (繼承來源 Object) |
| InitializeLifetimeService() |
取得一個終身服務物件以控制此實例的終身政策。 (繼承來源 MarshalByRefObject) |
| MemberwiseClone() |
建立目前 Object的淺層複本。 (繼承來源 Object) |
| MemberwiseClone(Boolean) |
建立一個 MarshalByRefObject 目前物件的淺層複製品。 (繼承來源 MarshalByRefObject) |
| ToString() |
將模組名稱轉換成字串。 |
事件
| 名稱 | Description |
|---|---|
| Disposed |
當元件被呼叫方法 Dispose() 時會發生。 (繼承來源 Component) |