共用方式為


ProcessModule.EntryPointAddress 屬性

定義

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

public:
 property IntPtr EntryPointAddress { IntPtr get(); };
public IntPtr EntryPointAddress { get; }
member this.EntryPointAddress : nativeint
Public ReadOnly Property EntryPointAddress As IntPtr

屬性值

IntPtr

nativeint

模組的進入點。

範例

下列程式碼範例會建立 Notepad.exe 應用程式的新處理序。 程式碼會逐一查看 ProcessModuleCollection 類別以取得集合中每個模組的 ProcessModule 物件。 ModuleNameEntryPointAddress 屬性是用來顯示每個模組的名稱與進入點位址。

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( "Entry point addresses of the modules associated with 'notepad' are:" );

// Display the 'EntryPointAddress' of each of the modules.
for ( int i = 0; i < myProcessModuleCollection->Count; i++ )
{
   myProcessModule = myProcessModuleCollection[ i ];
   Console::WriteLine( "{0} : {1}", myProcessModule->ModuleName, myProcessModule->EntryPointAddress );
}
myProcessModule = myProcess->MainModule;
Console::WriteLine( "The process's main module's EntryPointAddress is: {0}", myProcessModule->EntryPointAddress );
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("Entry point addresses of the modules "
        + "associated with 'notepad' are:");
    // Display the 'EntryPointAddress' of each of the modules.
    for (int i = 0; i < myProcessModuleCollection.Count; i++)
    {
        myProcessModule = myProcessModuleCollection[i];
        Console.WriteLine(myProcessModule.ModuleName + " : "
            + myProcessModule.EntryPointAddress);
    }
    // Get the main module associated with 'myProcess'.
    myProcessModule = myProcess.MainModule;
    Console.WriteLine("The process's main module's EntryPointAddress is: "
        + myProcessModule.EntryPointAddress);
    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("Entry point addresses of the modules " +
                   "associated with 'notepad' are:")
    ' Display the 'EntryPointAddress' of each of the modules.
    Dim i As Integer
    For i = 0 To myProcessModuleCollection.Count - 1
        myProcessModule = myProcessModuleCollection(i)
        Console.WriteLine(myProcessModule.ModuleName + " : " +
                                myProcessModule.EntryPointAddress.ToString())
    Next i
    ' Get the main module associated with 'myProcess'.
    myProcessModule = myProcess.MainModule
    Console.WriteLine("The process's main module's EntryPointAddress is: " +
                         myProcessModule.EntryPointAddress.ToString())
    myProcess.CloseMainWindow()
End Using

備註

模組的進入點是處理序啟動、執行緒啟動、處理序關閉及執行緒關閉期間呼叫之函式的位置。 雖然進入點不是 DllMain 函式的位址,但已足敷大部分案例使用。

注意

由於 Windows 載入元件的方式發生變更,因此一律會在 Windows 8 或 Windows 8.1 傳回 0,EntryPointAddress因此不應依賴這些平臺。

適用於