Marshal.GetTypedObjectForIUnknown-Methode: (IntPtr, Type)
Gibt ein verwaltetes Objekt eines angegebenen Typs zurück, das ein COM-Objekt darstellt.
Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Syntax
[SecurityCriticalAttribute]
public static object GetTypedObjectForIUnknown(
IntPtr pUnk,
Type t
)
public:
[SecurityCriticalAttribute]
static Object^ GetTypedObjectForIUnknown(
IntPtr pUnk,
Type^ t
)
[<SecurityCriticalAttribute>]
static member GetTypedObjectForIUnknown :
pUnk:nativeint *
t:Type -> Object
<SecurityCriticalAttribute>
Public Shared Function GetTypedObjectForIUnknown (
pUnk As IntPtr,
t As Type
) As Object
Parameter
pUnk
Type: System.IntPtrEin Zeiger auf die IUnknown-Schnittstelle des nicht verwalteten Objekts.
t
Type: System.TypeDer Typ der angeforderten verwalteten Klasse.
Rückgabewert
Type: System.Object
Eine Instanz der Klasse , die dem Type-Objekt entspricht, das das angeforderte nicht verwaltete COM-Objekt darstellt.
Ausnahmen
Exception | Condition |
---|---|
ArgumentException | t ist nicht mit dem Attribut System.Runtime.InteropServices.ComImportAttribute versehen. - oder - t ist ein Windows-Runtime-Typ. |
Hinweise
The t parameter must be either a COM-imported type or a subtype of a COM-imported type. In addition, t must be a type whose metadata was imported by the Tlbimp.exe (Type Library Importer) tool. This type must be a class and not an associated coclass interface, which carries the name of the COM class. For example, if Tlbimp.exe imports Myclass as a class called MyclassClass and as a coclass interface called Myclass, you must use MyclassClass (not Myclass) with this method. For additional information about imported classes and coclass interfaces, see Imported Type Conversion.
If an object has already been obtained for the pUnk parameter, t is ignored and the existing object is returned. pUnk represents anIUnknownhttps://go.microsoft.com/fwlink/?LinkId=148003 interface pointer; however, because all COM interfaces derive directly or indirectly from IUnknown, you can pass any COM interface to this method. The object returned by M:System.Runtime.InteropServices.Marshal.GetTypedObjectForIUnknown(System.IntPtr,System.Type) is a Runtime Callable Wrapper (RCW), which the common language runtime manages as it does any other managed object.
Sicherheit
requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.
Versionsinformationen
.NET Framework
Verfügbar seit 1.1
Siehe auch
ComImportAttribute
Marshal-Klasse
System.Runtime.InteropServices-Namespace
Zurück zum Anfang