DllImportAttribute.CallingConvention フィールド
アセンブリ: mscorlib (mscorlib.dll 内)


このフィールドを、CallingConvention 列挙体メンバの 1 つに設定します。CallingConvention フィールドの既定値は Winapi です。この場合の既定の呼び出し規約は StdCall です。

Visual Basic の開発者は、マネージ コードで DLL 関数を定義する際、Declare ステートメントの代わりに、DllImportAttribute を使用することがあります。CallingConvention フィールドの設定は、このような事例の 1 つです。
Imports System Imports Microsoft.VisualBasic Imports System.Runtime.InteropServices Public Class LibWrap ' Visual Basic does not support varargs, so all arguments must be ' explicitly defined. CallingConvention.Cdecl must be used since the stack ' is cleaned up by the caller. ' int printf(const char *format [, argument]...) <DllImport("msvcrt.dll", CallingConvention := CallingConvention.Cdecl)> _ Overloads Shared Function printf (_ format As String, i As Integer, d As Double) As Integer End Function <DllImport("msvcrt.dll", CallingConvention := CallingConvention.Cdecl)> _ Overloads Shared Function printf (_ format As String, i As Integer, s As String) As Integer End Function End Class 'LibWrap Public Class App Public Shared Sub Main() LibWrap.printf(ControlChars.CrLf + "Print params: %i %f", 99, 99.99) LibWrap.printf(ControlChars.CrLf + "Print params: %i %s", 99, _ "abcd") End Sub 'Main End Class 'App
using System; using System.Runtime.InteropServices; public class LibWrap { // C# doesn't support varargs so all arguments must be explicitly defined. // CallingConvention.Cdecl must be used since the stack is // cleaned up by the caller. // int printf(const char *format [, argument]...) [DllImport("msvcrt.dll", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)] public static extern int printf(String format, int i, double d); [DllImport("msvcrt.dll", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)] public static extern int printf(String format, int i, String s); } public class App { public static void Main() { LibWrap.printf("\nPrint params: %i %f", 99, 99.99); LibWrap.printf("\nPrint params: %i %s", 99, "abcd"); } }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDllImportAttribute.CallingConvention フィールドを検索する場合は、下記のリンクをクリックしてください。

- DllImportAttribute.CallingConvention フィールドのページへのリンク