MethodImportAttributes 列舉

定義

指定非受控方法匯入屬性的旗標。Specifies flags for the unmanaged method import attributes.

此列舉有 FlagsAttribute 屬性,因此其成員值可進行位元組合。

public enum class MethodImportAttributes
[System.Flags]
public enum MethodImportAttributes
[<System.Flags>]
type MethodImportAttributes = 
Public Enum MethodImportAttributes
繼承
MethodImportAttributes
屬性

欄位

BestFitMappingDisable 32

指定停用將 Unicode 字元轉換成 ANSI 字元時的最適合對應行為。Specifies that the best-fit mapping behavior when converting Unicode characters to ANSI characters is disabled.

BestFitMappingEnable 16

指定啟用將 Unicode 字元轉換為 ANSI 字元時的最適合對應行為。Specifies that the best-fit mapping behavior when converting Unicode characters to ANSI characters is enabled.

BestFitMappingMask 48

指定是否啟用或停用將 Unicode 字元轉換成 ANSI 字元時,最適合的對應行為。Specifies whether the best-fit mapping behavior when converting Unicode characters to ANSI characters is enabled or disabled.

CallingConventionCDecl 512

指定呼叫慣例為 CDecl。Specifies that the calling convention is CDecl.

CallingConventionFastCall 1280

指定呼叫慣例為 FastCall。Specifies that the calling convention is FastCall.

CallingConventionMask 1792

指定呼叫慣例。Specifies the calling convention.

CallingConventionStdCall 768

指定呼叫慣例為 StdCall。Specifies that the calling convention is StdCall.

CallingConventionThisCall 1024

指定呼叫慣例為 ThisCall。Specifies that the calling convention is ThisCall.

CallingConventionWinApi 256

指定使用預設的平臺呼叫慣例 (在 Windows x86 上 StdCall,CDecl on Linux x86) 。Specifies that the default platform calling convention is used (StdCall on Windows x86, CDecl on Linux x86).

CharSetAnsi 2

指定將字串封送處理為多位元組字元字串: Windows 上的系統預設 Windows (ANSI) 字碼頁,以及 Unix 上的 UTF-8。Specifies that strings are marshalled as multiple-byte character strings: the system default Windows (ANSI) code page on Windows, and UTF-8 on Unix.

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.

CharSetUnicode 4

指定將字串封送處理為 Unicode 2 位元組字元字串。Specifies that strings are marshalled as Unicode 2-byte character strings.

ExactSpelling 1

指定 Common Language Runtime 在搜尋已匯入的方法時,不應該嘗試具有特定字元集尾碼的進入點名稱。Specifies that the Common Language Runtime should not try an entry-point names with charset-specific suffixes when searching for the imported method.

None 0

指定預設方法匯入屬性。Specifies default method import attributes.

SetLastError 64

指定匯入的方法會在傳回之前呼叫 SetLastError Windows API 函式。Specifies that the imported method calls the SetLastError Windows API function before returning.

ThrowOnUnmappableCharDisable 8192

指定當無法轉換的 Unicode 字元轉換成 ANSI 字元時,不應擲回例外狀況。Specifies that an exception should not be thrown when an unmappable Unicode character is converted to an ANSI character.

ThrowOnUnmappableCharEnable 4096

指定當無法轉換的 Unicode 字元轉換成 ANSI 字元時,應擲回例外狀況。Specifies that an exception should be thrown when an unmappable Unicode character is converted to an ANSI character.

ThrowOnUnmappableCharMask 12288

指定當無法轉換的 Unicode 字元轉換成 ANSI 字元時,是否應擲回例外狀況。Specifies whether an exception should be thrown when an unmappable Unicode character is converted to an ANSI character.

備註

方法匯入屬性會搭配 MethodImport 結構使用。Method import attributes are used with the MethodImport structure.

若要檢查此列舉的值是否有特定的旗標,請使用 c # ) 中的位 AND (運算來合併該值與對應的遮罩常數, & 並將其結果與您需要檢查的旗標常數進行比較。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. 例如,若要檢查 CDecl 呼叫慣例,請使用如下的程式碼:For example, to check for CDecl calling convention, use a code like this:

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

如需非受控方法匯入以及這些屬性意義的詳細資訊,請參閱 DllImportAttributeFor more information about the unmanaged method import and the meaning of these attributes, see DllImportAttribute.

適用於