CallingConvention 列挙体とは? わかりやすく解説

CallingConvention 列挙体

アンマネージ コード実装されたメソッド呼び出すために必要な呼び出し規約指定します

名前空間: System.Runtime.InteropServices
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Enumeration CallingConvention
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public enum CallingConvention
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public enum class CallingConvention
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public enum CallingConvention
SerializableAttribute 
ComVisibleAttribute(true) 
public enum CallingConvention
メンバメンバ
解説解説
使用例使用例

Cdecl 呼び出し規約適用する例を次に示します呼び出し元によってスタッククリーンアップされるため、これは必ず使用する必要があります

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");
    }
}
using namespace System;
using namespace System::Runtime::InteropServices;
public ref class LibWrap
{
public:

   // 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)]
   static int printf( String^ format, int
 i, double d );

   [DllImport("msvcrt.dll",CharSet=CharSet::Ansi,CallingConvention=CallingConvention::Cdecl)]
   static int printf( String^ format, int
 i, String^ s );
};

int main()
{
   LibWrap::printf( "\nPrint params: %i %f", 99, 99.99 );
   LibWrap::printf( "\nPrint params: %i %s", 99, "abcd" );
}

import System.*;
import System.Runtime.InteropServices.*;

public class LibWrap
{
    // VJ# 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]... )
    /** @attribute DllImport("msvcrt.dll", CharSet = CharSet.Ansi, 
        CallingConvention = CallingConvention.Cdecl)
     */
    public static native int
 printf(String format, int i, double d);

    /** @attribute DllImport("msvcrt.dll", CharSet = CharSet.Ansi, 
        CallingConvention = CallingConvention.Cdecl)
     */
    public static native int
 printf(String format, int i, String s);
} //LibWrap

public class App
{
    public static void main(String[]
 args)
    {
        LibWrap.printf("\nPrint params: %i %f", 99, 99.99);
        LibWrap.printf("\nPrint params: %i %s", 99, "abcd");
    } //main
} //App
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
System.Runtime.InteropServices 名前空間
DllImportAttribute
System.Reflection.Emit


このページでは「.NET Framework クラス ライブラリ リファレンス」からCallingConvention 列挙体を検索した結果を表示しています。
Weblioに収録されているすべての辞書からCallingConvention 列挙体を検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からCallingConvention 列挙体 を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「CallingConvention 列挙体」の関連用語

CallingConvention 列挙体のお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CallingConvention 列挙体のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS