Marshal.AddRef(IntPtr) 메서드

정의

지정된 인터페이스의 참조 횟수를 증가시킵니다.

public:
 static int AddRef(IntPtr pUnk);
[System.Security.SecurityCritical]
public static int AddRef (IntPtr pUnk);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static int AddRef (IntPtr pUnk);
public static int AddRef (IntPtr pUnk);
[<System.Security.SecurityCritical>]
static member AddRef : nativeint -> int
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member AddRef : nativeint -> int
static member AddRef : nativeint -> int
Public Shared Function AddRef (pUnk As IntPtr) As Integer

매개 변수

pUnk
IntPtr

nativeint

증가시킬 인터페이스 참조 횟수입니다.

반환

Int32

pUnk 매개 변수에 대한 참조 횟수의 새 값입니다.

특성

설명

공용 언어 런타임은 COM 개체의 참조 수를 관리하므로 이 메서드를 직접 사용할 필요가 없습니다. 사용자 지정 마샬러 테스트와 같은 드문 경우이지만 개체의 수명을 수동으로 조작해야 할 수 있습니다. 호출 AddRef후 다음과 같은 Marshal.Release메서드를 사용하여 참조 수를 감소시켜야 합니다. 경우에 따라 불안정할 수 있으므로 반환 값 AddRef에 의존하지 마세요.

호출Marshal.GetComInterfaceForObjectMarshal.GetIUnknownForObject하거나 Marshal.GetIDispatchForObject IUnknown 인터페이스 포인터를 IntPtr 나타내는 값을 가져올 수 있습니다. 관리되는 개체에서 이러한 메서드와 메서드를 AddRef 사용하여 관리되는 개체의 COM 호출 가능 래퍼가 나타내는 COM 인터페이스를 가져올 수도 있습니다. 이 래퍼 유형의 세부 정보를 잘 모르는 경우 COM 호출 가능 래퍼를 참조하세요.

적용 대상

추가 정보