Пример #1
0
 public static ITEMIDLIST FromPidl(IntPtr pidl)
 {
     List<SHITEMID> list = new List<SHITEMID>();
     long num = pidl.ToInt64();
     int ofs = 0;
     for (ushort i = (ushort) Marshal.ReadInt16(pidl); i > 0; i = (ushort) Marshal.ReadInt16(pidl, ofs))
     {
         SHITEMID shitemid;
         shitemid = new SHITEMID {
             cb = i,
             abID = new byte[i - Marshal.SizeOf(shitemid.cb)]
         };
         Marshal.Copy(new IntPtr((num + ofs) + Marshal.SizeOf(shitemid.cb)), shitemid.abID, 0, shitemid.abID.Length);
         list.Add(shitemid);
         ofs += i;
     }
     return new ITEMIDLIST { mkid = list.ToArray() };
 }
Пример #2
0
 public static ITEMIDLIST FromByteArray(byte[] pidl)
 {
     List<SHITEMID> list = new List<SHITEMID>();
     int startIndex = 0;
     for (ushort i = BitConverter.ToUInt16(pidl, startIndex); i > 0; i = BitConverter.ToUInt16(pidl, startIndex))
     {
         SHITEMID shitemid;
         shitemid = new SHITEMID {
             cb = i,
             abID = new byte[i - Marshal.SizeOf(shitemid.cb)]
         };
         Array.Copy(pidl, startIndex + Marshal.SizeOf(shitemid.cb), shitemid.abID, 0, shitemid.abID.Length);
         list.Add(shitemid);
         startIndex += i;
     }
     return new ITEMIDLIST { mkid = list.ToArray() };
 }