internal static PIDL getParentPIDL(PIDL pidl, out PIDL relPIDL) { relPIDL = new PIDL(pidl, true); //0.21 if (pidl.Size == 0) { return(pidl); } IntPtr pParent = PIDL.ILClone(pidl.Ptr); relPIDL = getRelativePIDL(pidl); if (pParent == IntPtr.Zero || !PIDL.ILRemoveLastID2(ref pParent)) { return(DirectoryInfoEx.CSIDLtoPIDL(ShellAPI.CSIDL.DESKTOP)); } return(new PIDL(pParent, false)); //pParent will be freed by the PIDL. }