DllImportAttribute.EntryPoint Bidang

Definisi

Menunjukkan nama atau ordinal titik entri DLL yang akan dipanggil.

public: System::String ^ EntryPoint;
public string EntryPoint;
public string? EntryPoint;
val mutable EntryPoint : string
Public EntryPoint As String 

Nilai Bidang

Contoh

Contoh kode berikut menunjukkan cara menggunakan DllImportAttribute atribut untuk mengimpor fungsi Win32 MessageBox . Contoh kode menggunakan EntryPoint properti untuk menentukan fungsi yang akan diimpor lalu mengubah nama menjadi MyNewMessageBoxMethod.

using System;
using System.Runtime.InteropServices;

class Example
{
    // Use DllImport to import the Win32 MessageBox function.
    // Specify the method to import using the EntryPoint field and 
    // then change the name to MyNewMessageBoxMethod.
    [DllImport("user32.dll", CharSet = CharSet.Unicode, EntryPoint = "MessageBox")]
    public static extern int MyNewMessageBoxMethod(IntPtr hWnd, String text, String caption, uint type);
    
    static void Main()
    {
        // Call the MessageBox function using platform invoke.
        MyNewMessageBoxMethod(new IntPtr(0), "Hello World!", "Hello Dialog", 0);
    }
}
Imports System.Runtime.InteropServices

Module Example

    ' Use DllImport to import the Win32 MessageBox function.
    ' Specify the method to import using the EntryPoint field and 
    ' then change the name to MyNewMessageBoxMethod.
    <DllImport("user32.dll", CharSet:=CharSet.Unicode, EntryPoint:="MessageBox")> _
    Function MyNewMessageBoxMethod(ByVal hwnd As IntPtr, ByVal t As String, ByVal caption As String, ByVal t2 As UInt32) As Integer
    End Function


    Sub Main()
        ' Call the MessageBox function using platform invoke.
        MyNewMessageBoxMethod(New IntPtr(0), "Hello World!", "Hello Dialog", 0)
    End Sub

End Module

Keterangan

Anda dapat menentukan nama titik entri dengan menyediakan string yang menunjukkan nama DLL yang berisi titik masuk, atau Anda dapat mengidentifikasi titik entri berdasarkan ordinalnya. Ordinal diawali dengan tanda # , misalnya, #1. Jika Anda menghilangkan bidang ini, runtime bahasa umum menggunakan nama metode the.NET yang ditandai dengan DllImportAttribute.

Untuk informasi tambahan, lihat Mengidentifikasi Fungsi di DLL. Untuk contoh yang memperlihatkan cara menggunakan EntryPoint bidang , lihat Menentukan Titik Masuk.

Berlaku untuk

Lihat juga