mirror of https://github.com/dahall/Vanara.git
Fixed IDataObject.SetData extension to get CF_HDROP right with Unicode and changed DROPFILES.DangerousGetFileList to static function taking a DROPFILES pointer.
parent
275016379a
commit
34ce9eeaec
|
@ -588,7 +588,7 @@ namespace Vanara.PInvoke
|
||||||
case IEnumerable<string> strlist:
|
case IEnumerable<string> strlist:
|
||||||
// Handle HDROP specifically since its formatter cannot be specified.
|
// Handle HDROP specifically since its formatter cannot be specified.
|
||||||
if (CLIPFORMAT.CF_HDROP.Equals(formatId))
|
if (CLIPFORMAT.CF_HDROP.Equals(formatId))
|
||||||
mbr = new ClipboardHDROPFormatter().Write(strlist, charSet != CharSet.Ansi);
|
mbr = new ClipboardHDROPFormatter().Write(strlist, charSet == CharSet.Unicode || (charSet == CharSet.Auto && Marshal.SystemDefaultCharSize == 2));
|
||||||
else
|
else
|
||||||
mbr = strlist.MarshalToPtr(StringListPackMethod.Concatenated, MoveableHGlobalMemoryMethods.Instance.AllocMem, out _, charSet, 0,
|
mbr = strlist.MarshalToPtr(StringListPackMethod.Concatenated, MoveableHGlobalMemoryMethods.Instance.AllocMem, out _, charSet, 0,
|
||||||
MoveableHGlobalMemoryMethods.Instance.LockMem, MoveableHGlobalMemoryMethods.Instance.UnlockMem);
|
MoveableHGlobalMemoryMethods.Instance.LockMem, MoveableHGlobalMemoryMethods.Instance.UnlockMem);
|
||||||
|
@ -884,15 +884,16 @@ namespace Vanara.PInvoke
|
||||||
public bool fWide;
|
public bool fWide;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the file name array appended to this struture. It consists of a series of strings, each containing one file's fully
|
/// Gets the file name array appended to a <see cref="DROPFILES"/> struture in memory. It consists of a series of strings, each
|
||||||
/// qualified path. This method should only be called when the <see cref="DROPFILES"/> instance is a reference value pulled from
|
/// containing one file's fully qualified path. This method should only be called when <paramref name="pDropFiles"/> is a valid
|
||||||
/// the clipboard's HGLOBAL allocation.
|
/// pointer to a <see cref="DROPFILES"/> structure.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The file list.</returns>
|
/// <returns>The file list.</returns>
|
||||||
public string[] DangerousGetFileList()
|
public static string[] DangerousGetFileList(IntPtr pDropFiles)
|
||||||
{
|
{
|
||||||
using PinnedObject pinned = new(this);
|
SafeMoveableHGlobalHandle h = new(pDropFiles, false);
|
||||||
return ((IntPtr)pinned).ToStringEnum(fWide ? CharSet.Unicode : CharSet.Ansi, (int)pFiles).ToArray();
|
DROPFILES df = h.ToStructure<DROPFILES>();
|
||||||
|
return h.ToStringEnum(df.fWide ? CharSet.Unicode : CharSet.Ansi, (int)df.pFiles).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1820,9 +1821,10 @@ namespace Vanara.PInvoke
|
||||||
{
|
{
|
||||||
public object Read(IntPtr hGlobal)
|
public object Read(IntPtr hGlobal)
|
||||||
{
|
{
|
||||||
SafeMoveableHGlobalHandle h = new(hGlobal, false);
|
return DROPFILES.DangerousGetFileList(hGlobal);
|
||||||
DROPFILES df = h.ToStructure<DROPFILES>();
|
//SafeMoveableHGlobalHandle h = new(hGlobal, false);
|
||||||
return h.ToStringEnum(df.fWide ? CharSet.Unicode : CharSet.Ansi, Marshal.SizeOf(typeof(DROPFILES))).ToArray();
|
//DROPFILES df = h.ToStructure<DROPFILES>();
|
||||||
|
//return h.ToStringEnum(df.fWide ? CharSet.Unicode : CharSet.Ansi, Marshal.SizeOf(typeof(DROPFILES))).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntPtr Write(object value) => Write(value, Marshal.SystemDefaultCharSize != 1);
|
public IntPtr Write(object value) => Write(value, Marshal.SystemDefaultCharSize != 1);
|
||||||
|
|
Loading…
Reference in New Issue