internal ShellItem(ShellBrowser browser, ShellAPI.CSIDL specialFolder)
        {
            IntPtr pidl = IntPtr.Zero;
            ShellAPI.SHGetSpecialFolderLocation(IntPtr.Zero, specialFolder, out pidl);
            //
            IntPtr shellFolderPtr;
            this.browser = browser;
            //
            if (specialFolder == ShellAPI.CSIDL.DESKTOP)
            {
                ShellAPI.SHGetDesktopFolder(out shellFolderPtr);
                //
                this.shellFolderPtr = shellFolderPtr;
                this.shellFolder = (IShellFolder)Marshal.GetTypedObjectForIUnknown(shellFolderPtr, typeof(IShellFolder));
            }
            else
            {
                this.shellFolder = GetShellFolderFromPidl(pidl, out shellFolderPtr);
                //
                this.parentItem = browser.DesktopItem;
            }
            //
            subFiles = new ShellItemCollection(this);
            subFolders = new ShellItemCollection(this);

            pidlRel = new PIDL(pidl, false);

            ShellAPI.SHFILEINFO info = new ShellAPI.SHFILEINFO();
            ShellAPI.SHGetFileInfo(pidlRel.Ptr, 0, ref info, ShellAPI.cbFileInfo,
                ShellAPI.SHGFI.PIDL | ShellAPI.SHGFI.TYPENAME | ShellAPI.SHGFI.SYSICONINDEX | ShellAPI.SHGFI.DISPLAYNAME);

            type = info.szTypeName;
            text = info.szDisplayName;
            //
            StringBuilder pathBuilder = new StringBuilder(ShellAPI.MAX_PATH);
            ShellAPI.SHGetFolderPath(
                    IntPtr.Zero, specialFolder,
                    IntPtr.Zero, ShellAPI.SHGFP.TYPE_CURRENT, pathBuilder);
            this.path = pathBuilder.ToString();
            //
            if (specialFolder == ShellAPI.CSIDL.DESKTOP)
            {
                ShellImageList.SetIconIndex(this, info.iIcon, false);
                ShellImageList.SetIconIndex(this, info.iIcon, true);
                //
                SetAttributesDesktop(this);
            }
            else
            {
                SetAttributesFolder(this);
                SetInfo(this);
            }
            sortFlag = 1;
        }
        public ShellBrowserUpdater(ShellBrowser br)
        {
            this.br = br;
            CreateHandle(new CreateParams());

            ShellAPI.SHChangeNotifyEntry entry = new ShellAPI.SHChangeNotifyEntry();
            entry.pIdl = br.DesktopItem.PIDLRel.Ptr;
            entry.Recursively = true;

            notifyId = ShellAPI.SHChangeNotifyRegister(
                this.Handle,
                ShellAPI.SHCNRF.InterruptLevel | ShellAPI.SHCNRF.ShellLevel,
                ShellAPI.SHCNE.ALLEVENTS | ShellAPI.SHCNE.INTERRUPT,
                ShellAPI.WM.SH_NOTIFY,
                1,
                new ShellAPI.SHChangeNotifyEntry[] { entry });
        }
Beispiel #3
0
        public ShellBrowserUpdater(ShellBrowser br)
        {
            this.br = br;
            CreateHandle(new CreateParams());

            ShellAPI.SHChangeNotifyEntry entry = new ShellAPI.SHChangeNotifyEntry();
            entry.pIdl        = br.DesktopItem.PIDLRel.Ptr;
            entry.Recursively = true;

            notifyId = ShellAPI.SHChangeNotifyRegister(
                this.Handle,
                ShellAPI.SHCNRF.InterruptLevel | ShellAPI.SHCNRF.ShellLevel,
                ShellAPI.SHCNE.ALLEVENTS | ShellAPI.SHCNE.INTERRUPT,
                ShellAPI.WM.SH_NOTIFY,
                1,
                new ShellAPI.SHChangeNotifyEntry[] { entry });
        }
        internal ShellItem(ShellBrowser browser, ShellItem parentItem, IntPtr pidl, IntPtr shellFolderPtr)
        {
            this.browser = browser;

            this.parentItem = parentItem;
            this.shellFolderPtr = shellFolderPtr;
            this.shellFolder = (IShellFolder)Marshal.GetTypedObjectForIUnknown(shellFolderPtr, typeof(IShellFolder));
            subFiles = new ShellItemCollection(this);
            subFolders = new ShellItemCollection(this);

            pidlRel = new PIDL(pidl, false);

            SetText(this);
            SetPath(this);
            SetAttributesFolder(this);
            SetInfo(this);

            sortFlag = MakeSortFlag(this);
        }
        internal ShellItem(ShellBrowser browser, ShellItem parentItem, IntPtr pidl)
        {
            this.browser = browser;

            this.parentItem = parentItem;

            pidlRel = new PIDL(pidl, false);

            SetText(this);
            SetPath(this);
            SetAttributesFile(this);
            SetInfo(this);

            sortFlag = MakeSortFlag(this);
        }