DllImportAttribute.ExactSpelling Champ

Définition

Contrôle si le CharSet champ entraîne la recherche de noms de points d’entrée autres que ceux spécifiés dans le Common Language Runtime.

public: bool ExactSpelling;
public bool ExactSpelling;
val mutable ExactSpelling : bool
Public ExactSpelling As Boolean 

Valeur de champ

Exemples

Dans certains cas, Visual Basic développeurs utilisent le DllImportAttribute, au lieu d’utiliser l’instruction Declare, pour définir une fonction DLL dans le code managé. La définition du ExactSpelling champ est l’un de ces cas.

[DllImport("user32.dll", CharSet = CharSet::Ansi, ExactSpelling = true)]
int MessageBoxA(IntPtr hWnd, String^ Text,
    String^ Caption, unsigned int Type);
internal static class NativeMethods
{
    [DllImport("user32.dll", CharSet = CharSet.Unicode,
        ExactSpelling = true)]
    internal static extern int MessageBoxW(
        IntPtr hWnd, string lpText, string lpCption, uint uType);
}
Friend Class NativeMethods
    <DllImport("user32.dll", ExactSpelling:=False)>
    Friend Shared Function MessageBox(hWnd As IntPtr, lpText As String,
        lpCaption As String, uType As UInteger) As Integer
    End Function
End Class

Remarques

Si false, le nom du point d’entrée ajouté avec la lettre A est appelé lorsque le DllImportAttribute.CharSet champ est défini CharSet.Ansisur , et le nom du point d’entrée ajouté avec la lettre W est appelé lorsque le DllImportAttribute.CharSet champ est défini sur le CharSet.Unicode. En règle générale, les compilateurs managés définissent ce champ.

Le tableau suivant montre la relation entre les champs et ExactSpelling les CharSet champs, en fonction des valeurs par défaut imposées par le langage de programmation. Vous pouvez remplacer le paramètre par défaut, mais faites-le avec précaution.

Language Institut national américain des normes (ANSI) Unicode Auto
Visual Basic ExactSpelling :=True ExactSpelling :=True ExactSpelling :=False
C# ExactSpelling=false ExactSpelling=false ExactSpelling=false
C++ ExactSpelling=false ExactSpelling=false ExactSpelling=false

S’applique à