DllImportAttribute.EntryPoint Campo

Definición

Indica el nombre u ordinal del punto de entrada de la DLL al que se va a llamar.

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

Valor de campo

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar el DllImportAttribute atributo para importar la función Win32 MessageBox . En el ejemplo de código se usa la EntryPoint propiedad para especificar la función que se va a importar y, a continuación, se cambia el nombre a 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

Comentarios

Puede especificar el nombre del punto de entrada proporcionando una cadena que indica el nombre del archivo DLL que contiene el punto de entrada, o bien puede identificar el punto de entrada por su ordinal. Los ordinales tienen el prefijo # , por ejemplo, #1. Si omite este campo, Common Language Runtime usa el nombre de the.NET método marcado con .DllImportAttribute

Para obtener más información, consulte Identificación de funciones en archivos DLL. Para obtener ejemplos que muestran cómo usar el EntryPoint campo , vea Especificar un punto de entrada.

Se aplica a

Consulte también