DllImportAttribute.EntryPoint フィールド

定義

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

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

フィールド値

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

注釈

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

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

適用対象

こちらもご覧ください