DllImportAttribute.ExactSpelling Field
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Controls whether the CharSet field causes the common language runtime to search an unmanaged DLL for entry-point names other than the one specified.
public: bool ExactSpelling;
public bool ExactSpelling;
val mutable ExactSpelling : bool
Public ExactSpelling As Boolean
In some cases, Visual Basic developers use the DllImportAttribute, instead of using the Declare
statement, to define a DLL function in managed code. Setting the ExactSpelling field is one of those cases.
[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
If false
, the entry point name appended with the letter A is invoked when the DllImportAttribute.CharSet field is set to CharSet.Ansi
, and the entry-point name appended with the letter W is invoked when the DllImportAttribute.CharSet field is set to the CharSet.Unicode
. Typically, managed compilers set this field.
The following table shows the relationship between the CharSet and ExactSpelling fields, based on default values imposed by the programming language. You can override the default setting, but do so with caution.
Language | 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 |
Termék | Verziók |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |
.NET-visszajelzés
A(z) .NET egy nyílt forráskód projekt. Visszajelzés adásához válasszon egy hivatkozást: