DllImportAttribute.EntryPoint Fält
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Anger namnet eller ordningstalet för den DLL-startpunkt som ska anropas.
public: System::String ^ EntryPoint;
public string EntryPoint;
public string? EntryPoint;
val mutable EntryPoint : string
Public EntryPoint As String
Fältvärde
Exempel
I följande kodexempel visas hur du använder DllImportAttribute attributet för att importera win32-funktionen MessageBox . Kodexemplet använder EntryPoint egenskapen för att ange den funktion som ska importeras och ändrar sedan namnet till 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
Kommentarer
Du kan ange startpunktsnamnet genom att ange en sträng som anger namnet på den DLL som innehåller startpunkten, eller så kan du identifiera startpunkten med dess ordning. Ordningstal är prefix med #-tecknet, till exempel #1. Om du utelämnar det här fältet använder common language runtime namnet på den.NET metod som har markerats med DllImportAttribute.
Mer information finns i Identifiera funktioner i DLL:er. Exempel som visar hur du använder fältet EntryPoint finns i Ange en startpunkt.