private ShellContextMenu.IShellFolder GetParentFolder(string folderName)
 {
     ShellContextMenu.IShellFolder result;
     if (null == this._oParentFolder)
     {
         ShellContextMenu.IShellFolder desktopFolder = this.GetDesktopFolder();
         if (null == desktopFolder)
         {
             result = null;
             return(result);
         }
         IntPtr zero = IntPtr.Zero;
         uint   num  = 0u;
         ShellContextMenu.SFGAO sFGAO = (ShellContextMenu.SFGAO) 0u;
         int num2 = desktopFolder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, folderName, ref num, out zero, ref sFGAO);
         if (0 != num2)
         {
             result = null;
             return(result);
         }
         IntPtr intPtr = Marshal.AllocCoTaskMem(524);
         Marshal.WriteInt32(intPtr, 0, 0);
         num2 = this._oDesktopFolder.GetDisplayNameOf(zero, ShellContextMenu.SHGNO.FORPARSING, intPtr);
         StringBuilder stringBuilder = new StringBuilder(260);
         ShellContextMenu.StrRetToBuf(intPtr, zero, stringBuilder, 260);
         Marshal.FreeCoTaskMem(intPtr);
         intPtr = IntPtr.Zero;
         this._strParentFolder = stringBuilder.ToString();
         IntPtr zero2 = IntPtr.Zero;
         num2 = desktopFolder.BindToObject(zero, IntPtr.Zero, ref ShellContextMenu.IID_IShellFolder, out zero2);
         Marshal.FreeCoTaskMem(zero);
         if (0 != num2)
         {
             result = null;
             return(result);
         }
         this._oParentFolder = (ShellContextMenu.IShellFolder)Marshal.GetTypedObjectForIUnknown(zero2, typeof(ShellContextMenu.IShellFolder));
     }
     result = this._oParentFolder;
     return(result);
 }
 protected IntPtr[] GetPIDLs(DirectoryInfo[] arrFI)
 {
     IntPtr[] result;
     if (arrFI == null || 0 == arrFI.Length)
     {
         result = null;
     }
     else
     {
         ShellContextMenu.IShellFolder parentFolder = this.GetParentFolder(arrFI[0].Parent.FullName);
         if (null == parentFolder)
         {
             result = null;
         }
         else
         {
             IntPtr[] array = new IntPtr[arrFI.Length];
             int      num   = 0;
             for (int i = 0; i < arrFI.Length; i++)
             {
                 DirectoryInfo          directoryInfo = arrFI[i];
                 uint                   num2          = 0u;
                 ShellContextMenu.SFGAO sFGAO         = (ShellContextMenu.SFGAO) 0u;
                 IntPtr                 zero          = IntPtr.Zero;
                 int num3 = parentFolder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, directoryInfo.Name, ref num2, out zero, ref sFGAO);
                 if (0 != num3)
                 {
                     this.FreePIDLs(array);
                     result = null;
                     return(result);
                 }
                 array[num] = zero;
                 num++;
             }
             result = array;
         }
     }
     return(result);
 }