// Called just after invoking the COM method. The IntPtr is the same one that just got returned // from MarshalManagedToNative. The return value is unused. public object MarshalNativeToManaged(IntPtr pNativeData) { Marshal.PtrToStructure(pNativeData, m_prop); m_prop = null; return m_prop; }
// It appears this routine is never called public void CleanUpManagedData(object ManagedObj) { m_prop = null; }
public IntPtr MarshalManagedToNative(object managedObj) { IntPtr p; // Cast the object back to a PropVariant m_prop = managedObj as PropVariant; if(m_prop != null) { // Release any memory currently allocated m_prop.Clear(); // Create an appropriately sized buffer, blank it, and send it to // the marshaler to make the COM call with. int iSize = GetNativeDataSize(); p = Marshal.AllocCoTaskMem(iSize); if(IntPtr.Size == 4) { Marshal.WriteInt64(p, 0); Marshal.WriteInt64(p, 8, 0); } else { Marshal.WriteInt64(p, 0); Marshal.WriteInt64(p, 8, 0); Marshal.WriteInt64(p, 16, 0); } } else { p = IntPtr.Zero; } return p; }
public void Copy(PropVariant pval) { if(pval == null) { throw new Exception("Null PropVariant sent to Copy"); } pval.Clear(); PropVariantCopy(pval, this); }