Marshal.GetDelegateForFunctionPointer 메서드

정의

오버로드

GetDelegateForFunctionPointer(IntPtr, Type)
사용되지 않음.

관리되지 않는 함수 포인터를 대리자로 변환합니다.

GetDelegateForFunctionPointer<TDelegate>(IntPtr)

관리되지 않는 함수 포인터를 지정된 형식의 대리자로 변환합니다.

GetDelegateForFunctionPointer(IntPtr, Type)

Source:
Marshal.cs
Source:
Marshal.cs
Source:
Marshal.cs

주의

GetDelegateForFunctionPointer(IntPtr, Type) may be unavailable in future releases. Instead, use GetDelegateForFunctionPointer<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296521

관리되지 않는 함수 포인터를 대리자로 변환합니다.

public:
 static Delegate ^ GetDelegateForFunctionPointer(IntPtr ptr, Type ^ t);
[System.Obsolete("GetDelegateForFunctionPointer(IntPtr, Type) may be unavailable in future releases. Instead, use GetDelegateForFunctionPointer<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296521")]
[System.Security.SecurityCritical]
public static Delegate GetDelegateForFunctionPointer (IntPtr ptr, Type t);
public static Delegate GetDelegateForFunctionPointer (IntPtr ptr, Type t);
[System.Security.SecurityCritical]
public static Delegate GetDelegateForFunctionPointer (IntPtr ptr, Type t);
[<System.Obsolete("GetDelegateForFunctionPointer(IntPtr, Type) may be unavailable in future releases. Instead, use GetDelegateForFunctionPointer<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296521")>]
[<System.Security.SecurityCritical>]
static member GetDelegateForFunctionPointer : nativeint * Type -> Delegate
static member GetDelegateForFunctionPointer : nativeint * Type -> Delegate
[<System.Security.SecurityCritical>]
static member GetDelegateForFunctionPointer : nativeint * Type -> Delegate
Public Shared Function GetDelegateForFunctionPointer (ptr As IntPtr, t As Type) As Delegate

매개 변수

ptr
IntPtr

nativeint

변환할 관리되지 않는 함수 포인터입니다.

t
Type

반환될 대리자의 형식입니다.

반환

적절한 대리자 형식으로 캐스팅될 수 있는 대리자 인스턴스입니다.

특성

예외

t 매개 변수가 대리자가 아니거나 제네릭인 경우

ptr 매개 변수가 null인 경우

또는

t 매개 변수가 null인 경우

설명

GetFunctionPointerForDelegate 메서드를 GetDelegateForFunctionPointer 사용하여 양방향으로 대리자를 마샬링할 수 있습니다. 를 사용하여 GetDelegateForFunctionPointerptr 을 로 System.IntPtr가져옵니다. 를 System.IntPtr 호출 GetFunctionPointerForDelegate 하여 관리되는 대리자를 가져오고 매개 변수로 전달할 수 있습니다. 그런 다음 관리되지 않는 메서드 내에서 를 호출할 수 있습니다. 매개 변수 마샬러는 함수 포인터를 .NET Framework 2.0 이상 버전의 대리자에 마샬링할 수도 있습니다.

ptr기본 플랫폼 호출 규칙을 사용하여 관리되지 않는 메서드를 호출하는 대리자로 변환됩니다. 를 대리자에 적용하여 UnmanagedFunctionPointerAttribute 호출 규칙을 설정할 수 있습니다.

메서드에는 GetDelegateForFunctionPointer 다음과 같은 제한 사항이 있습니다.

  • 제네릭은 interop 시나리오에서 지원되지 않습니다.

  • 이 메서드는 관리되지 않는 순수 함수 포인터에만 사용할 수 있습니다.

  • C++를 통해 얻은 함수 포인터에는 이 메서드를 사용할 수 없습니다.

적용 대상

GetDelegateForFunctionPointer<TDelegate>(IntPtr)

Source:
Marshal.cs
Source:
Marshal.cs
Source:
Marshal.cs

관리되지 않는 함수 포인터를 지정된 형식의 대리자로 변환합니다.

public:
generic <typename TDelegate>
 static TDelegate GetDelegateForFunctionPointer(IntPtr ptr);
[System.Security.SecurityCritical]
public static TDelegate GetDelegateForFunctionPointer<TDelegate> (IntPtr ptr);
public static TDelegate GetDelegateForFunctionPointer<TDelegate> (IntPtr ptr);
[<System.Security.SecurityCritical>]
static member GetDelegateForFunctionPointer : nativeint -> 'Delegate
static member GetDelegateForFunctionPointer : nativeint -> 'Delegate
Public Shared Function GetDelegateForFunctionPointer(Of TDelegate) (ptr As IntPtr) As TDelegate

형식 매개 변수

TDelegate

반환할 대리자의 형식입니다.

매개 변수

ptr
IntPtr

nativeint

변환할 관리되지 않는 함수 포인터입니다.

반환

TDelegate

지정된 대리자 형식의 인스턴스입니다.

특성

예외

TDelegate 제네릭 매개 변수가 대리자가 아니거나 개방형 제네릭 형식입니다.

ptr 매개 변수가 null인 경우

설명

GetFunctionPointerForDelegate<TDelegate>(TDelegate) 메서드를 GetDelegateForFunctionPointer<TDelegate>(IntPtr) 사용하여 양방향으로 대리자를 마샬링할 수 있습니다.

ptr기본 플랫폼 호출 규칙을 사용하여 관리되지 않는 메서드를 호출하는 대리자로 변환됩니다. 를 대리자에 적용하여 UnmanagedFunctionPointerAttribute 호출 규칙을 설정할 수 있습니다.

메서드에는 GetDelegateForFunctionPointer<TDelegate>(IntPtr) 다음과 같은 제한 사항이 있습니다.

  • 제네릭은 interop 시나리오에서 지원되지 않습니다.

  • 이 메서드는 관리되지 않는 순수 함수 포인터에만 사용할 수 있습니다.

  • C++를 통해 얻은 함수 포인터에는 이 메서드를 사용할 수 없습니다.

적용 대상