CopyHGlobal() public static method

public static CopyHGlobal ( SafeGlobalAllocHandle data ) : SafeGlobalAllocHandle
data SafeGlobalAllocHandle
return SafeGlobalAllocHandle
Ejemplo n.º 1
0
        void IDataObject.GetData(FORMATETC[] fmt, STGMEDIUM[] m)
        {
            STGMEDIUM retMedium = new STGMEDIUM();

            if (fmt == null || fmt.Length < 1)
            {
                return;
            }

            foreach (DataCacheEntry e in this.entries)
            {
                if (e.Format.cfFormat == fmt[0].cfFormat /*|| fmt[0].cfFormat == InternalNativeMethods.CF_HDROP*/)
                {
                    retMedium.tymed = e.Format.tymed;

                    // Caller must delete the memory.
                    retMedium.unionmember = DragDropHelper.CopyHGlobal(new IntPtr(e.Data));
                    break;
                }
            }

            if (m != null && m.Length > 0)
            {
                m[0] = retMedium;
            }
        }
Ejemplo n.º 2
0
        void IDataObject.GetData(FORMATETC[] fmt, STGMEDIUM[] m)
        {
            STGMEDIUM retMedium = new STGMEDIUM();

            if (fmt == null || fmt.Length < 1)
            {
                return;
            }

            SafeGlobalAllocHandle copy = null;

            foreach (DataCacheEntry e in this.entries)
            {
                if (e.Format.cfFormat == fmt[0].cfFormat /*|| fmt[0].cfFormat == InternalNativeMethods.CF_HDROP*/)
                {
                    retMedium.tymed = e.Format.tymed;

                    // Caller must delete the memory.
                    copy = DragDropHelper.CopyHGlobal(e.Data);
                    retMedium.unionmember = copy.DangerousGetHandle();
                    break;
                }
            }

            if (m != null && m.Length > 0)
            {
                m[0] = retMedium;
                if (copy != null)
                {
                    copy.SetHandleAsInvalid();
                }
            }
        }