Exemplo n.º 1
0
        public IntPtr GetDisplayName(SIGDN sigdnName)
        {
            if (sigdnName == SIGDN.FILESYSPATH)
            {
                StringBuilder result = new StringBuilder(FileSystem.MAX_PATH);
                if (!ILShell32.SHGetPathFromIDList(_pidl, result))
                {
                    throw new ArgumentException();
                }
                return(Marshal.StringToHGlobalUni(result.ToString()));
            }
            else
            {
                //IShellFolder parentFolder = GetParent().GetIShellFolder();
                IntPtr        childPidl = ILShell32.ILFindLastID(_pidl);
                StringBuilder builder   = new StringBuilder(FileSystem.MAX_PATH);
                builder.Length = 0; // TODO
                //STRRET strret = new STRRET();

                //TODO
                //parentFolder.GetDisplayNameOf(childPidl,
                //    (SHGNO)((int)sigdnName & 0xffff), out strret);
                //ShlWapi.StrRetToBuf(ref strret, childPidl, builder,
                //    (uint)builder.Capacity);
                return(Marshal.StringToHGlobalUni(builder.ToString()));
            }
        }
Exemplo n.º 2
0
        public void Initialise(IntPtr pidl, string path)
        {
            this.PIDL         = pidl;
            this.RelativePIDL = ILShell32.ILFindLastID(pidl);

            IntPtr folderPidl = PIDL;

            SHFILEINFO?info = PidlManager.GetShFileInfo(pidl);
            var        dir  = System.IO.Path.GetDirectoryName(path);

            if ((info.Value.Attributes & SFGAO.SFGAO_FOLDER) == 0)
            {
                // Item folder
                var handle = PidlManager.FromPath(dir);
                folderPidl = handle.pidl;
                SHFILEINFO?info2 = PidlManager.GetShFileInfo(folderPidl);
                if (!info2.HasValue)
                {
                    return; // new DirectoryNotFoundException
                }
                ParentItem              = new ShellItem();
                ParentItem.PIDL         = folderPidl;
                ParentItem.RelativePIDL = ILShell32.ILFindLastID(folderPidl);

                ParentItem.DisplayName  = info2.Value.szDisplayName;
                ParentItem.Attributes   = (SFGAO)info2.Value.Attributes;
                ParentItem.IsFolder     = (Attributes & SFGAO.SFGAO_FOLDER) != 0;
                ParentItem.IsFileSystem = (Attributes & SFGAO.SFGAO_FILESYSTEM) != 0;
            }

            //IShellItem i = ILShell32.SHCreateItemFromParsingName(path, IntPtr.Zero,
            //           typeof(IShellItem).GUID);
            int          hr = 0;
            IShellFolder pShellFolderInterface =
                IFolder(folderPidl, desktopShellFolder.Value.ShellFolderInterface, ref hr);

            if (pShellFolderInterface == null)
            {
                throw new NullReferenceException("SheelObject ShellFolderInterface error");
            }

            DisplayName  = info.Value.szDisplayName;
            Attributes   = (SFGAO)info.Value.Attributes;
            IsFolder     = (Attributes & SFGAO.SFGAO_FOLDER) != 0;
            IsFileSystem = (Attributes & SFGAO.SFGAO_FILESYSTEM) != 0;

            if ((info.Value.Attributes & SFGAO.SFGAO_FOLDER) == 0)
            {
                this.ParentItem.InitFolder(folderPidl, dir, pShellFolderInterface, false);
            }
            else if (dir == null && path.EndsWith(@":\"))
            {
                this.InitFolder(PIDL, path, pShellFolderInterface, false);
            }
            else
            {
                this.InitFolder(PIDL, dir, pShellFolderInterface, false);
            }
        }
Exemplo n.º 3
0
        public int Compare(IShellItem psi, SICHINT hint)
        {
            ShellItemImpl other       = (ShellItemImpl)psi;
            ShellItemImpl myParent    = GetParent();
            ShellItemImpl theirParent = other.GetParent();

            if (Shell32.ILIsEqual(myParent._pidl, theirParent._pidl))
            {
                return(myParent.GetIShellFolder().CompareIDs(
                           // (SHCIDS)
                           (IntPtr)hint,
                           ILShell32.ILFindLastID(_pidl),
                           ILShell32.ILFindLastID(other._pidl)));
            }
            else
            {
                return(1);
            }
        }