DllImportAttribute.EntryPoint Veld

Definitie

Geeft de naam of rangschikk aan van het DLL-toegangspunt dat moet worden aangeroepen.

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

Waarde van veld

Voorbeelden

In het volgende codevoorbeeld ziet u hoe u het DllImportAttribute kenmerk gebruikt om de Win32-functie MessageBox te importeren. In het codevoorbeeld wordt de EntryPoint eigenschap gebruikt om de functie op te geven die moet worden geïmporteerd en wijzigt vervolgens de naam in 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

Opmerkingen

U kunt de naam van het invoerpunt opgeven door een tekenreeks op te geven die de naam aangeeft van het DLL-bestand met het toegangspunt, of u kunt het toegangspunt identificeren op basis van de rangschikking. Rangtelwoorden worden voorafgegaan door het #-teken, bijvoorbeeld #1. Als u dit veld weglaat, gebruikt de algemene taalruntime de naam van de methode.NET die is gemarkeerd met de DllImportAttribute.

Zie Functies identificeren in DLL's voor meer informatie. Zie Een toegangspunt opgeven voor voorbeelden die laten zien hoe u het EntryPoint veld gebruikt.

Van toepassing op

Zie ook