ProcessModule 类

表示加载到特定进程中的 .dll 或 .exe 文件。

**命名空间:**System.Diagnostics
**程序集:**System(在 system.dll 中)

语法

声明
Public Class ProcessModule
    Inherits Component
用法
Dim instance As ProcessModule
public class ProcessModule : Component
public ref class ProcessModule : public Component
public class ProcessModule extends Component
public class ProcessModule extends Component

备注

模块指的是可执行文件或动态链接库 (DLL)。每个进程包含一个或多个模块。可以使用此类来获取有关模块的信息。

示例

Dim 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()
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();
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();

继承层次结构

System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
      System.Diagnostics.ProcessModule

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

ProcessModule 成员
System.Diagnostics 命名空间