Пример #1
0
        public List <Uri> GetResources(Uri uri)
        {
            var list = new List <Uri>();

            var item = GetItem(uri);

            IntPtr pidl = Shell32.SHGetIDListFromObject(item);

            try{
                var psf = Shell32.SHBindToObject <IShellFolder>(null, pidl, null);
                try{
                    IEnumIDList peidl = psf.EnumObjects(OwnerHwnd, EnumConst);

                    if (peidl == null)
                    {
                        return(list);
                    }
                    try{
                        while (true)
                        {
                            IntPtr pidl2;
                            int    num;
                            peidl.Next(1, out pidl2, out num);
                            if (num == 0)
                            {
                                break;
                            }
                            try{
                                IntPtr pidl3 = Shell32.ILCombine(pidl, pidl2);
                                list.Add(GetShellUri(pidl3, true));
                            }finally{
                                Marshal.FreeCoTaskMem(pidl2);
                            }
                        }
                    }finally{
                        Marshal.FinalReleaseComObject(peidl);
                    }
                }finally{
                    Marshal.FinalReleaseComObject(psf);
                }
            }finally{
                Marshal.FreeCoTaskMem(pidl);
            }

            return(list);
        }
Пример #2
0
            public override List <ResourceInfo> GetResources()
            {
                var list = new List <ResourceInfo>();

                var psf = Shell32.SHBindToObject <IShellFolder>(null, pidl, null);

                try{
                    IEnumIDList peidl = psf.EnumObjects(fs.OwnerHwnd, EnumConst);

                    if (peidl == null)
                    {
                        return(list);
                    }
                    try{
                        while (true)
                        {
                            IntPtr pidl2;
                            int    num;
                            peidl.Next(1, out pidl2, out num);
                            if (num == 0)
                            {
                                break;
                            }
                            try{
                                IntPtr pidl3 = Shell32.ILCombine(pidl, pidl2);
                                list.Add(new ShellFileHandle(pidl3, fs, true));
                            }finally{
                                Marshal.FreeCoTaskMem(pidl2);
                            }
                        }
                    }finally{
                        Marshal.FinalReleaseComObject(peidl);
                    }
                }finally{
                    Marshal.FinalReleaseComObject(psf);
                }

                return(list);
            }