ProcessModule.EntryPointAddress 屬性

定義

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

C#
public IntPtr EntryPointAddress { get; }

屬性值

IntPtr

模組的進入點。

範例

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

C#
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();
}

備註

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

備註

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

適用於

產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1