Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Gibt die Aufrufkonvention eines Einstiegspunktes an.
Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public CallingConvention As CallingConvention
'Usage
Dim instance As DllImportAttribute
Dim value As CallingConvention
value = instance.CallingConvention
instance.CallingConvention = value
public CallingConvention CallingConvention
public:
CallingConvention CallingConvention
public CallingConvention CallingConvention
public var CallingConvention : CallingConvention
Hinweise
Sie legen dieses Feld auf einen der CallingConvention-Enumerationsmember fest. Der Standardwert für das CallingConvention-Feld ist Winapi. Für diesen stellt wiederum die StdCall-Konvention den Standard dar.
Weitere Informationen finden Sie unter "Calling Convention" in der MSDN Library (nur auf Englisch verfügbar).
Beispiel
In einigen Fällen verwenden Visual Basic-Entwickler DllImportAttribute anstelle der Declare-Anweisung, um eine DLL-Funktion in verwaltetem Code zu definieren. Ein solcher Fall ist beim Festlegen des CallingConvention-Felds gegeben.
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");
}
}
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
DllImportAttribute-Klasse
DllImportAttribute-Member
System.Runtime.InteropServices-Namespace
CallingConvention-Enumeration