ProcessModule ProcessModule ProcessModule ProcessModule Class

Definizione

Rappresenta un file con estensione dll o exe caricato in un determinato processo.Represents a.dll or .exe file that is loaded into a particular process.

public ref class ProcessModule : System::ComponentModel::Component
public class ProcessModule : System.ComponentModel.Component
type ProcessModule = class
    inherit Component
Public Class ProcessModule
Inherits Component
Ereditarietà

Esempi

L'esempio di codice riportato di seguito dimostra come usare la classe ProcessModule per ottenere e visualizzare informazioni su tutti i moduli usati dall'applicazione Notepad.exe.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.

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

Commenti

Un modulo è un file eseguibile o una libreria a collegamento dinamico (DLL).A module is an executable file or a dynamic link library (DLL). Ogni processo è costituito da uno o più moduli.Each process consists of one or more modules. È possibile usare questa classe per ottenere informazioni sul modulo.You can use this class to get information about the module.

Importante

Il tipo implementa l'interfaccia IDisposable.This type implements the IDisposable interface. Dopo aver utilizzato il tipo, è necessario eliminarlo direttamente o indirettamente.When you have finished using the type, you should dispose of it either directly or indirectly. Per eliminare direttamente il tipo, chiamare il metodo Dispose in un blocco try/catch.To dispose of the type directly, call its Dispose method in a try/catch block. Per eliminarlo indirettamente, utilizzare un costrutto di linguaggio come ad esempio using in C# o Using in Visual Basic.To dispose of it indirectly, use a language construct such as using (in C#) or Using (in Visual Basic). Per altre informazioni, vedere la sezione "Uso di un oggetto che implementa IDisposable" nell'argomento relativo all'interfaccia IDisposable.For more information, see the "Using an Object that Implements IDisposable" section in the IDisposable interface topic.

Proprietà

BaseAddress BaseAddress BaseAddress BaseAddress

Ottiene l'indirizzo di memoria in cui è stato caricato il modulo.Gets the memory address where the module was loaded.

CanRaiseEvents CanRaiseEvents CanRaiseEvents CanRaiseEvents

Ottiene un valore che indica se il componente può generare un evento.Gets a value indicating whether the component can raise an event.

(Inherited from Component)
Container Container Container Container

Ottiene il IContainer che contiene il Component.Gets the IContainer that contains the Component.

(Inherited from Component)
DesignMode DesignMode DesignMode DesignMode

Ottiene un valore che indica se il Component si trova in modalità progettazione.Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
EntryPointAddress EntryPointAddress EntryPointAddress EntryPointAddress

Ottiene l'indirizzo di memoria per la funzione che viene eseguita quando il sistema carica ed esegue il modulo.Gets the memory address for the function that runs when the system loads and runs the module.

Events Events Events Events

Ottiene l'elenco dei gestori eventi allegati a questo Component.Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
FileName FileName FileName FileName

Ottiene il percorso completo del modulo.Gets the full path to the module.

FileVersionInfo FileVersionInfo FileVersionInfo FileVersionInfo

Ottiene le informazioni sulla versione relative al modulo.Gets version information about the module.

ModuleMemorySize ModuleMemorySize ModuleMemorySize ModuleMemorySize

Ottiene la quantità di memoria necessaria per caricare il modulo.Gets the amount of memory that is required to load the module.

ModuleName ModuleName ModuleName ModuleName

Ottiene il nome del modulo del processo.Gets the name of the process module.

Site Site Site Site

Ottiene o imposta l'oggetto ISite di Component.Gets or sets the ISite of the Component.

(Inherited from Component)

Metodi

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

Consente di creare un oggetto che contiene tutte le informazioni rilevanti necessarie per la generazione del proxy utilizzato per effettuare la comunicazione con un oggetto remoto.Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

Rilascia tutte le risorse usate da Component.Releases all resources used by the Component.

(Inherited from Component)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Rilascia le risorse non gestite usate da Component e, facoltativamente, le risorse gestite.Releases the unmanaged resources used by the Component and optionally releases the managed resources.

(Inherited from Component)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Funge da funzione hash predefinita.Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Consente di recuperare l'oggetto servizio di durata corrente per controllare i criteri di durata per l'istanza.Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

Consente di restituire un oggetto che rappresenta un servizio fornito da Component o dal relativo Container.Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetType() GetType() GetType() GetType()

Ottiene l'oggetto Type dell'istanza corrente.Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Ottiene un oggetto servizio di durata per controllare i criteri di durata per questa istanza.Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Crea una copia dei riferimenti dell'oggetto MarshalByRefObject corrente.Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
ToString() ToString() ToString() ToString()

Converte il nome del modulo in una stringa.Converts the name of the module to a string.

Eventi

Disposed Disposed Disposed Disposed

Si verifica quando il componente viene eliminato da una chiamata al metodo Dispose().Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)

Sicurezza

LinkDemand
per l'attendibilità totale per il chiamante immediato.for full trust for the immediate caller. Questa classe non può essere usata da codice parzialmente attendibile.This class cannot be used by partially trusted code.

InheritanceDemand
per l'attendibilità totale per gli eredi.for full trust for inheritors. Questa classe non può essere ereditata da codice parzialmente attendibile.This class cannot be inherited by partially trusted code.

Si applica a