DllImportAttribute.EntryPoint Campo

Definição

Indica o nome ou o ordinal do ponto de entrada DLL a ser chamado.

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

Valor do campo

Exemplos

O exemplo de código a seguir mostra como usar o DllImportAttribute atributo para importar a função Win32 MessageBox . O exemplo de código usa a EntryPoint propriedade para especificar a função a ser importada e, em seguida, altera o nome para 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

Comentários

Você pode especificar o nome do ponto de entrada fornecendo uma cadeia de caracteres indicando o nome da DLL que contém o ponto de entrada ou pode identificar o ponto de entrada por seu ordinal. Ordinais são prefixados com o sinal #, por exemplo, nº 1. Se você omitir esse campo, o Common Language Runtime usará o nome de the.NET método marcado com o DllImportAttribute.

Para obter informações adicionais, consulte Identificando funções em DLLs. Para obter exemplos que mostram como usar o EntryPoint campo, consulte Especificando um ponto de entrada.

Aplica-se a

Confira também