Represents a .dll or .exe file that is loaded into a particular process.
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
The following code sample demonstrates how to use the ProcessModule class to get and display information about all the modules that are used by the Notepad.exe application.
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
A module is an executable file or a dynamic link library (DLL). Each process consists of one or more modules. You can use this class to get information about the module.
Important
This type implements the IDisposable interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its Dispose method in a try
/catch
block. To dispose of it indirectly, use a language construct such as using
(in C#) or Using
(in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the IDisposable interface topic.
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide. In this articleWas this page helpful?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4