public bool Equals(_DROPFILES other) { return(this.pFiles == other.pFiles && this.X == other.X && this.Y == other.Y && this.fNC == other.fNC && this.fWide == other.fWide); }
private IntPtr PackageSelectionData(StringBuilder sb, bool addEndFormatDelimiter) { if (sb == null || sb.ToString().Length == 0 || this.ItemsDraggedOrCutOrCopied.Count == 0) { return(IntPtr.Zero); } // Double null at end. if (addEndFormatDelimiter) { if (sb.ToString()[sb.Length - 1] != '\0') { sb.Append('\0'); } } // We request unmanaged permission to execute the below. new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); _DROPFILES df = new _DROPFILES(); int dwSize = Marshal.SizeOf(df); Int16 wideChar = 0; int dwChar = Marshal.SizeOf(wideChar); int structSize = dwSize + ((sb.Length + 1) * dwChar); IntPtr ptr = Marshal.AllocHGlobal(structSize); df.pFiles = dwSize; df.fWide = 1; IntPtr data = IntPtr.Zero; try { data = UnsafeNativeMethods.GlobalLock(ptr); Marshal.StructureToPtr(df, data, false); IntPtr strData = new IntPtr((long)data + dwSize); DragDropHelper.CopyStringToHGlobal(sb.ToString(), strData, structSize); } finally { if (data != IntPtr.Zero) { UnsafeNativeMethods.GlobalUnLock(data); } } return(ptr); }
/// <summary> /// Returns the data packed after the DROPFILES structure. /// </summary> /// <param name="dropHandle"></param> /// <returns></returns> internal static string GetData(IntPtr dropHandle) { IntPtr data = UnsafeNativeMethods.GlobalLock(dropHandle); try { _DROPFILES df = (_DROPFILES)Marshal.PtrToStructure(data, typeof(_DROPFILES)); if (df.fWide != 0) { IntPtr pdata = new IntPtr((long)data + df.pFiles); return(Marshal.PtrToStringUni(pdata)); } } finally { if (data != null) { UnsafeNativeMethods.GlobalUnLock(data); } } return(null); }
private IntPtr PackageSelectionData(StringBuilder sb, bool addEndFormatDelimiter) { if(sb == null || sb.ToString().Length == 0 || this.ItemsDraggedOrCutOrCopied.Count == 0) { return IntPtr.Zero; } // Double null at end. if(addEndFormatDelimiter) { if(sb.ToString()[sb.Length - 1] != '\0') { sb.Append('\0'); } } // We request unmanaged permission to execute the below. new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); _DROPFILES df = new _DROPFILES(); int dwSize = Marshal.SizeOf(df); Int16 wideChar = 0; int dwChar = Marshal.SizeOf(wideChar); int structSize = dwSize + ((sb.Length + 1) * dwChar); IntPtr ptr = Marshal.AllocHGlobal(structSize); df.pFiles = dwSize; df.fWide = 1; IntPtr data = IntPtr.Zero; try { data = UnsafeNativeMethods.GlobalLock(ptr); Marshal.StructureToPtr(df, data, false); IntPtr strData = new IntPtr((long)data + dwSize); DragDropHelper.CopyStringToHGlobal(sb.ToString(), strData, structSize); } finally { if(data != IntPtr.Zero) UnsafeNativeMethods.GlobalUnLock(data); } return ptr; }
public bool Equals(_DROPFILES other) { return this.pFiles == other.pFiles && this.X == other.X && this.Y == other.Y && this.fNC == other.fNC && this.fWide == other.fWide; }