VariantWrapper(Object) Constructor
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the VariantWrapper class for the specified Object parameter.
public:
VariantWrapper(System::Object ^ obj);
public VariantWrapper (object obj);
public VariantWrapper (object? obj);
new System.Runtime.InteropServices.VariantWrapper : obj -> System.Runtime.InteropServices.VariantWrapper
Public Sub New (obj As Object)
Parameters
- obj
- Object
The object to marshal.
Examples
The following code example demonstrates how to use the VariantWrapper class to wrap an Object that the interop marshaler passes as VT_VARIANT | VT_BYREF
.
// Create an instance of an unmanged COM object.
UnmanagedComClass UnmanagedComClassInstance = new UnmanagedComClass();
// Create a string to pass to the COM object.
string helloString = "Hello World!";
// Wrap the string with the VariantWrapper class.
object var = new System.Runtime.InteropServices.VariantWrapper(helloString);
// Pass the wrapped object.
UnmanagedComClassInstance.MethodWithStringRefParam(ref var);
' Create an instance of an unmanged COM object.
Dim UnmanagedComClassInstance As New UnmanagedComClass()
' Create a string to pass to the COM object.
Dim helloString As String = "Hello World!"
' Wrap the string with the VariantWrapper class.
Dim var As Object = New System.Runtime.InteropServices.VariantWrapper(helloString)
' Pass the wrapped object.
UnmanagedComClassInstance.MethodWithStringRefParam(var)
Applies to
Sodelujte z nami v storitvi GitHub
Vir za to vsebino najdete v storitvi GitHub, kjer lahko tudi ustvarite in pregledate težave in zahtevke za uveljavitev sprememb. Če želite več informacij, glejte naš vodnik za sodelavce.
Povratne informacije
https://aka.ms/ContentUserFeedback.
Kmalu na voljo: V letu 2024 bomo ukinili storitev Težave v storitvi GitHub kot mehanizem za povratne informacije za vsebino in jo zamenjali z novim sistemom za povratne informacije. Za več informacij si oglejte:Pošlji in prikaži povratne informacije za