Freigeben über


DllImportAttribute.EntryPoint-Feld

Gibt den Namen oder die Ordnungszahl des aufzurufenden DLL-Einstiegspunktes an.

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public EntryPoint As String
'Usage
Dim instance As DllImportAttribute
Dim value As String

value = instance.EntryPoint

instance.EntryPoint = value
public string EntryPoint
public:
String^ EntryPoint
public String EntryPoint
public var EntryPoint : String

Hinweise

Sie können den Einstiegspunktnamen festlegen, indem Sie eine Zeichenfolge mit dem Namen der DLL angeben, die den Einstiegspunkt enthält, oder Sie können den Einstiegspunkt anhand seiner Ordnungszahl angeben. Ordnungszahlen sind mit dem Präfix # versehen, z. B. #1. Wenn Sie dieses Feld nicht festlegen, verwendet die Common Language Runtime den Namen der .NET-Methode, die mit DllImportAttribute markiert ist.

Weitere Informationen finden Sie unter Identifizieren von Funktionen in DLLs. Beispiele zur Verwendung des EntryPoint-Felds finden Sie unter Angeben eines Einstiegspunktes.

Beispiel

Im folgenden Codebeispiel wird die Verwendung des DllImportAttribute-Attributs zum Importieren der Win32-Funktion MessageBox gezeigt. Im Codebeispiel wird die EntryPoint-Eigenschaft verwendet, um die zu importierende Funktion anzugeben, und anschließend der Name in MyNewMessageBoxMethod geändert.

Imports System
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.Auto, 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
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.Auto, 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);
    }
}

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

DllImportAttribute-Klasse
DllImportAttribute-Member
System.Runtime.InteropServices-Namespace
DllImportAttribute-Klasse