Discussion:
Drag & Drop Support (Shell IDList Array)
(too old to reply)
Jason Newell
2006-01-06 15:34:45 UTC
Permalink
Raw Message
* This post was copied from the
microsoft.public.dotnet.framework.interop forum. Can anyone here help
me? Thanks.


Greetings all,

I'm writing a C# 2.0 Windows application which I'm adding Drag & Drop
support. Very straight forward for the most part but I'm needing some
help dealing with "Shell IDList Array" data. I've done my homework on
researching and this is what I have.

[StructLayout(LayoutKind.Sequential)]
public struct CIDA
{
public uint cidl;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst = 1)]
public uint[] aoffset;
}

protected override void OnDragOver(DragEventArgs drgevent)
{
base.OnDragOver(drgevent);

try
{
MemoryStream data = (MemoryStream)drgevent.Data.GetData("Shell
IDList Array");
byte[] b = data.ToArray();
IntPtr p = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CIDA)));
Marshal.Copy(b, 0, p, b.Length);

CIDA cida = (CIDA)Marshal.PtrToStructure(p, typeof(CIDA));

}
catch (System.Exception e)
{
Console.WriteLine(e.Message);
}
}

Looking at the CIDA structure, I can see in the cidl member correctly
states the number of dragged items. My question is, can someone help me
with the code to emumerate the PIDL's and get the paths to the files
being dragged.

Any help is apprecited. Thanks.

Jason Newell
Michael Phillips, Jr.
2006-01-06 18:07:51 UTC
Permalink
Raw Message
Once you have the number of items, use SHGetPathFromIDList
to get the name of the item from the pidl.

At aoffset[0] you have the parent folder.
At aoffset[i+1] you have the item.
* This post was copied from the microsoft.public.dotnet.framework.interop
forum. Can anyone here help me? Thanks.
Greetings all,
I'm writing a C# 2.0 Windows application which I'm adding Drag & Drop
support. Very straight forward for the most part but I'm needing some
help dealing with "Shell IDList Array" data. I've done my homework on
researching and this is what I have.
[StructLayout(LayoutKind.Sequential)]
public struct CIDA
{
public uint cidl;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst = 1)]
public uint[] aoffset;
}
protected override void OnDragOver(DragEventArgs drgevent)
{
base.OnDragOver(drgevent);
try
{
MemoryStream data = (MemoryStream)drgevent.Data.GetData("Shell
IDList Array");
byte[] b = data.ToArray();
IntPtr p = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CIDA)));
Marshal.Copy(b, 0, p, b.Length);
CIDA cida = (CIDA)Marshal.PtrToStructure(p, typeof(CIDA));
}
catch (System.Exception e)
{
Console.WriteLine(e.Message);
}
}
Looking at the CIDA structure, I can see in the cidl member correctly
states the number of dragged items. My question is, can someone help me
with the code to emumerate the PIDL's and get the paths to the files being
dragged.
Any help is apprecited. Thanks.
Jason Newell
stoyac
2010-05-18 15:05:46 UTC
Permalink
Raw Message
Post by Jason Newell
* This post was copied from the
microsoft.public.dotnet.framework.interop forum. Can anyone here help
me? Thanks.
Greetings all,
I'm writing a C# 2.0 Windows application which I'm adding Drag & Drop
support. Very straight forward for the most part but I'm needing some
help dealing with "Shell IDList Array" data. I've done my homework on
researching and this is what I have.
[StructLayout(LayoutKind.Sequential)]
public struct CIDA
{
public uint cidl;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst = 1)]
public uint[] aoffset;
}
protected override void OnDragOver(DragEventArgs drgevent)
{
base.OnDragOver(drgevent);
try
{
MemoryStream data = (MemoryStream)drgevent.Data.GetData("Shell
IDList Array");
byte[] b = data.ToArray();
IntPtr p = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CIDA)));
Marshal.Copy(b, 0, p, b.Length);
CIDA cida = (CIDA)Marshal.PtrToStructure(p, typeof(CIDA));
}
catch (System.Exception e)
{
Console.WriteLine(e.Message);
}
}
Looking at the CIDA structure, I can see in the cidl member correctly
states the number of dragged items. My question is, can someone help me
with the code to emumerate the PIDL's and get the paths to the files
being dragged.
Any help is apprecited. Thanks.
Jason Newell
See als
http://www.eggheadcafe.com/software/aspnet/31276866/getting-path-from-a-shell.aspx
http://serialcs.svn.sourceforge.net/viewvc/serialcs/trunk/serialcs/Clip.cs?view=markup
http://cetoys.svn.sourceforge.net/viewvc/cetoys/trunk/cetoys/ce/clipboard.c?view=log
Loading...