IntPtr ptr = Marshal.GetIUnknownForObject(myObject); Marshal.AddRef(ptr);In this example, the Marshal.GetIUnknownForObject method retrieves the IUnknown interface of an object, and the Marshal.AddRef method increases the reference count of the object. Package/Library: System.Runtime.InteropServices.