Conventions for Calling DLL Functions

The following calling conventions are supported when calling DLL functions:
  • __stdcall
  • __cdecl

The __stdcall calling convention is used by default when calling DLL functions. This calling convention is used by all Windows API DLL functions.

You can change the calling convention for a DLL function by using the CallingConvention property of the DllFunctionOptions annotation.

Example

The following code example declares a DLL function with the __decl calling convention:
@Dll("msvcrt.dll")
public interface IMsVisualCRuntime {
  @FunctionOptions(callingConvention=CallingConvention.Cdecl)
  double cos(double inputInRadians);
}