System.Runtime.InteropServices.CallingConvention Enumeration

Specifies the calling convention required to call methods implemented in unmanaged code.

Syntax

[System.Runtime.InteropServices.ComVisible(true)]
public enum CallingConvention

Remarks

Always use the System.Runtime.InteropServices.CallingConvention enumeration rather than the System.Runtime.InteropServices.CALLCONV enumeration to specify a calling convention in managed code. The latter exists only for the sake of COM definitions. The System.Runtime.InteropServices.CallingConvention enumeration is used by System.Runtime.InteropServices.DllImportAttribute and several classes in System.Reflection.Emit to dynamically emit platform invoke signatures.

Members

Member NameDescription
Cdecl

The caller cleans the stack. This enables calling functions with varargs, which makes it appropriate to use for methods that accept a variable number of parameters, such as Printf.

FastCall

This calling convention is not supported.

StdCall

The callee cleans the stack. This is the default convention for calling unmanaged functions with platform invoke.

ThisCall

The first parameter is the this pointer and is stored in register ECX. Other parameters are pushed on the stack. This calling convention is used to call methods on classes exported from an unmanaged DLL.

Winapi

This member is not actually a calling convention, but instead uses the default platform calling convention. For example, on Windows the default is CallingConvention.StdCall and on Windows CE.NET it is CallingConvention.Cdecl.

Requirements

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0