CALLCONV 枚举

定义

标识 METHODDATA 结构中描述的方法所使用的调用约定。Identifies the calling convention used by a method described in a METHODDATA structure.

public enum class CALLCONV
[System.Serializable]
public enum CALLCONV
type CALLCONV = 
Public Enum CALLCONV
继承
CALLCONV
属性

字段

CC_CDECL 1

指示对方法使用 C 声明 (CDECL) 调用约定。Indicates that the C declaration (CDECL) calling convention is used for a method.

CC_MACPASCAL 3

指示对方法使用 Macintosh Pascal (MACPASCAL) 调用约定。Indicates that the Macintosh Pascal (MACPASCAL) calling convention is used for a method.

CC_MAX 9

指示 CALLCONV 枚举的结尾。Indicates the end of the CALLCONV enumeration.

CC_MPWCDECL 7

指示对方法使用 Macintosh Programmers' Workbench (MPW) CDECL 调用约定。Indicates that the Macintosh Programmers' Workbench (MPW) CDECL calling convention is used for a method.

CC_MPWPASCAL 8

指示对方法使用 Macintosh Programmers' Workbench (MPW) PASCAL 调用约定。Indicates that the Macintosh Programmers' Workbench (MPW) PASCAL calling convention is used for a method.

CC_MSCPASCAL 2

指示对方法使用 MSC Pascal (MSCPASCAL) 调用约定。Indicates that the MSC Pascal (MSCPASCAL) calling convention is used for a method.

CC_PASCAL 2

指示对方法使用 Pascal 调用约定。Indicates that the Pascal calling convention is used for a method.

CC_RESERVED 5

保留此值供将来使用。This value is reserved for future use.

CC_STDCALL 4

指示对方法使用标准调用约定 (STDCALL)。Indicates that the standard calling convention (STDCALL) is used for a method.

CC_SYSCALL 6

指示对方法使用标准 SYSCALL 调用约定。Indicates that the standard SYSCALL calling convention is used for a method.

注解

此类中的调用约定描述函数如何传递参数和返回值。The calling conventions in this class describe how functions pass arguments and return values. 它们指定了为被调用函数设置参数的顺序, 这些参数存储在中 (寄存器或内存中), 而谁 (调用方或被调用函数) 负责在函数返回后清理堆栈。They specify the order in which parameters are set up for the called functions, where the parameters are stored (in registers or in memory), and who (caller or called function) is responsible for cleaning up the stack after the function returns. 例如:For example:

  • CC_CDECL 使用 C 语言的命名和调用约定。CC_CDECL uses the naming and calling conventions of the C language. 调用方按反向 (从右到左) 顺序将参数推送到堆栈上, 并在函数返回后清理堆栈。The caller pushes the parameters onto the stack in reverse (right-to-left) order, and cleans the stack after the function returns. 此调用约定使你能够使用调用函数varargs, 这使它适合用于接受可变数目的参数的方法, 例如 C 运行时函数printf、_printf_l、wprintf、_wprintf_lThis calling convention enables you to call functions with varargs, which makes it appropriate for use with methods that accept a variable number of parameters, such as the C run-time functions printf, _printf_l, wprintf, _wprintf_l.

  • CC_PASCAL 使用 Pascal 调用约定。CC_PASCAL uses the Pascal calling convention. 调用方按从左到右的顺序将参数推送到堆栈上。The caller pushes the parameters onto the stack in left-to-right order. 被调用的函数将在返回前清理堆栈。The called function cleans the stack before returning.

  • CC_STDCALL 是 Win32 函数的标准调用约定。CC_STDCALL is the standard calling convention for Win32 functions. 这是通过平台调用调用非托管函数的默认约定。It is the default convention for calling unmanaged functions with platform invoke. 调用方按反向 (从右到左) 顺序将参数推送到堆栈上, 并且被调用的函数在返回前清理堆栈。The caller pushes the parameters onto the stack in reverse (right to left) order, and the called function cleans the stack before returning.

  • CC_SYSCALL 类似于 CDECL, 该参数按从右到左的顺序推送。CC_SYSCALL is similar to CDECL in that arguments are pushed from right to left. 不保留 EAX、ECX 和 EDX 寄存器。The EAX, ECX, and EDX registers are not preserved.

这些调用约定标识符由.NET Framework.NET Framework Windows Embedded CEWindows Embedded CE 、平台和自动化使用。These calling convention identifiers are used by the .NET Framework.NET Framework, the Windows Embedded CEWindows Embedded CE platform, and by Automation.

当本机代码中的 COM 方法返回 HRESULT 时, 公共语言运行时将引发异常。The common language runtime throws an exception when a COM method in native code returns an HRESULT. 有关更多信息,请参见 How to: Map HRESULTs and ExceptionsFor more information, see How to: Map HRESULTs and Exceptions.

适用于

另请参阅