static void Main(string[] args) { // <snippet1> // 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); // </snippet1> }
public Variant(VariantWrapper wrapper) { if (wrapper == null) throw new ArgumentNullException("wrapper"); varType = (ushort)(VarEnum.VT_VARIANT | VarEnum.VT_BYREF); reserved1 = 0; reserved2 = 0; reserved3 = 0; boolvalue = 0; ptr1 = IntPtr.Zero; ptr2 = IntPtr.Zero; // Allocate memory for the VT_BYREF VT_VARIANT. ptr1 = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Variant))); // Move the wrapped object into the memory. Marshal.GetNativeVariantForObject(wrapper.WrappedObject, ptr1); }
public virtual extern void Add([In] System.Runtime.InteropServices.VariantWrapper pValue);
public int OnScriptTerminate(VariantWrapper varResult, ref System.Runtime.InteropServices.ComTypes.EXCEPINFO excepInfo) { return 0; }