DllImportAttribute.EntryPoint フィールド

定義

呼び出す DLL エントリ ポイントの名前または序数を指定します。

C#
public string EntryPoint;
C#
public string? EntryPoint;

フィールド値

次のコード例は、 DllImportAttribute 属性を使用して Win32 MessageBox 関数をインポートする方法を示しています。 このコード例では、 プロパティを EntryPoint 使用してインポートする関数を指定し、名前を に MyNewMessageBoxMethod変更します。

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

注釈

エントリ ポイント名を指定するには、エントリ ポイントを含む DLL の名前を示す文字列を指定するか、エントリ ポイントを序数で識別できます。 序数には、#1 などの # 記号が付きます。 このフィールドを省略した場合、共通言語ランタイムでは、 でマークされた the.NET メソッドの名前が DllImportAttribute使用されます。

詳細については、「 DLL での関数の識別」を参照してください。 フィールドの使用方法を示す例については、「エントリ ポイントのEntryPoint指定」を参照してください。

適用対象

製品 バージョン
.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, 10
.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 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

こちらもご覧ください