Muokkaa

Jaa


MethodImportAttributes Enum

Definition

Specifies flags for the unmanaged method import attributes.

This enumeration supports a bitwise combination of its member values.

public enum class MethodImportAttributes
[System.Flags]
public enum MethodImportAttributes
[<System.Flags>]
type MethodImportAttributes = 
Public Enum MethodImportAttributes
Inheritance
MethodImportAttributes
Attributes

Fields

Name Value Description
None 0

Specifies default method import attributes.

ExactSpelling 1

Specifies that the Common Language Runtime should not try an entry-point names with charset-specific suffixes when searching for the imported method.

CharSetAnsi 2

Specifies that strings are marshalled as multiple-byte character strings: the system default Windows (ANSI) code page on Windows, and UTF-8 on Unix.

CharSetUnicode 4

Specifies that strings are marshalled as Unicode 2-byte character strings.

CharSetAuto 6

Specifies that the character set is chosen automatically. See Charsets and marshaling for details.

CharSetMask 6

Specifies the character set used for string marshalling.

BestFitMappingEnable 16

Specifies that the best-fit mapping behavior when converting Unicode characters to ANSI characters is enabled.

BestFitMappingDisable 32

Specifies that the best-fit mapping behavior when converting Unicode characters to ANSI characters is disabled.

BestFitMappingMask 48

Specifies whether the best-fit mapping behavior when converting Unicode characters to ANSI characters is enabled or disabled.

SetLastError 64

Specifies that the imported method calls the SetLastError Windows API function before returning.

CallingConventionWinApi 256

Specifies that the default platform calling convention is used.

CallingConventionCDecl 512

Specifies that the calling convention is CDecl.

CallingConventionStdCall 768

Specifies that the calling convention is StdCall.

CallingConventionThisCall 1024

Specifies that the calling convention is ThisCall.

CallingConventionFastCall 1280

Specifies that the calling convention is FastCall.

CallingConventionMask 1792

Specifies the calling convention.

ThrowOnUnmappableCharEnable 4096

Specifies that an exception should be thrown when an unmappable Unicode character is converted to an ANSI character.

ThrowOnUnmappableCharDisable 8192

Specifies that an exception should not be thrown when an unmappable Unicode character is converted to an ANSI character.

ThrowOnUnmappableCharMask 12288

Specifies whether an exception should be thrown when an unmappable Unicode character is converted to an ANSI character.

Remarks

Method import attributes are used with the MethodImport structure.

To check whether a value of this enumeration has the specific flag, combine that value with the corresponding mask constant using the bitwise AND operation (& in C#) and compare its result with the constant of the flag you need to check. For example, to check for CDecl calling convention, use a code like this:

if((attributes & MethodImportAttributes.CallingConventionMask) == MethodImportAttributes.CallingConventionCDecl)
{
    // The calling convention is CDecl
}

For more information about the unmanaged method import and the meaning of these attributes, see DllImportAttribute.

Applies to