DllImportAttribute.EntryPoint フィールド
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
呼び出す 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指定」を参照してください。
製品 | バージョン |
---|---|
.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 | 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。