Ejemplo n.º 1
0
        // 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)
        {
            m_Control.cbStruct = Marshal.ReadInt32(pNativeData);
            m_Control.dwLineID = Marshal.ReadInt32(pNativeData, 4);
            m_Control.dwControl = Marshal.ReadInt32(pNativeData, 8);
            m_Control.cControls = Marshal.ReadInt32(pNativeData, 12);
            m_Control.cbmxctrl = Marshal.ReadInt32(pNativeData, 16);
            m_Control.pamxctrl = new MixerControl[m_Control.cControls];

            IntPtr pData = new IntPtr(pNativeData.ToInt64() + iMixLineContSize);

            for (int x = 0; x < m_Control.cControls; x++)
            {
                m_Control.pamxctrl[x] = new MixerControl();
                IntPtr ip = new IntPtr(pData.ToInt64() + (x * iMixContSize));
                Marshal.PtrToStructure(ip, m_Control.pamxctrl[x]);
            }

            m_Control = null;

            return m_Control;
        }
Ejemplo n.º 2
0
 // It appears this routine is never called
 public void CleanUpManagedData(object ManagedObj)
 {
     m_Control = null;
 }
Ejemplo n.º 3
0
        public IntPtr MarshalManagedToNative(object managedObj)
        {
            IntPtr p;

            // Cast the object back to a PropVariant
            m_Control = managedObj as MixerLineControls;

            if (m_Control != null)
            {
                // Create an appropriately sized buffer, blank it, and send it to
                // the marshaler to make the COM call with.
                int iSize2 = m_Control.cControls * iMixContSize;

                p = Marshal.AllocCoTaskMem(iMixLineContSize + iSize2);
#if DEBUG
                for (int x = 0; x < iMixLineContSize + iSize2; x++)
                {
                    Marshal.WriteByte(p, x, 0xcc);
                }
#endif
                Marshal.StructureToPtr(m_Control, p, false);
                Marshal.WriteIntPtr(p, iMixLineContSize - IntPtr.Size, new IntPtr(p.ToInt64() + iMixLineContSize));
            }
            else
            {
                p = IntPtr.Zero;
            }

            return p;
        }