Exemple #1
0
        public IEnumerable <STATSTGWrapper> EnumElements(bool read_stream_data)
        {
            List <STATSTGWrapper> ret = new List <STATSTGWrapper>();

            _stg.EnumElements(0, IntPtr.Zero, 0, out IEnumSTATSTG enum_stg);
            try
            {
                ComTypes.STATSTG[] stat = new ComTypes.STATSTG[1];
                uint fetched;
                while (enum_stg.Next(1, stat, out fetched) == 0)
                {
                    STGTY  type  = (STGTY)stat[0].type;
                    byte[] bytes = new byte[0];
                    if (read_stream_data && type == STGTY.Stream)
                    {
                        bytes = ReadStream(stat[0].pwcsName);
                    }
                    ret.Add(new STATSTGWrapper(stat[0].pwcsName, stat[0], bytes));
                }
            }
            finally
            {
                Marshal.ReleaseComObject(enum_stg);
            }
            return(ret);
        }
        private void PopulateTree(IStorage stg, TreeNode root)
        {
            IEnumSTATSTG enum_stg;

            stg.EnumElements(0, IntPtr.Zero, 0, out enum_stg);
            STATSTG[] stat = new STATSTG[1];
            uint      fetched;

            while (enum_stg.Next(1, stat, out fetched) == 0)
            {
                STGTY    type  = (STGTY)stat[0].type;
                TreeNode node  = new TreeNode(stat[0].pwcsName);
                byte[]   bytes = new byte[0];
                node.ImageIndex         = 2;
                node.SelectedImageIndex = 2;
                switch (type)
                {
                case STGTY.Storage:
                    PopulateTree(stg.OpenStorage(stat[0].pwcsName, IntPtr.Zero, STGM.READ | STGM.SHARE_EXCLUSIVE, IntPtr.Zero, 0), node);
                    node.ImageIndex         = 0;
                    node.SelectedImageIndex = 0;
                    break;

                case STGTY.Stream:
                    bytes = ReadStream(stg, stat[0].pwcsName, (int)stat[0].cbSize);
                    break;

                default:
                    break;
                }
                node.Tag = new STATSTGWrapper(stat[0], bytes);

                root.Nodes.Add(node);
            }
        }
Exemple #3
0
        private void PopulateTree(IStorage stg, TreeNode root)
        {
            STATSTG stg_stat = new STATSTG();

            stg.Stat(stg_stat, 0);
            root.Tag = new STATSTGWrapper(EscapeStorageName(stg_stat.pwcsName), stg_stat, new byte[0]);
            IEnumSTATSTG enum_stg;

            stg.EnumElements(0, IntPtr.Zero, 0, out enum_stg);
            STATSTG[] stat = new STATSTG[1];
            uint      fetched;

            while (enum_stg.Next(1, stat, out fetched) == 0)
            {
                STGTY    type  = (STGTY)stat[0].type;
                TreeNode node  = new TreeNode(EscapeStorageName(stat[0].pwcsName));
                byte[]   bytes = new byte[0];
                node.ImageIndex         = 2;
                node.SelectedImageIndex = 2;
                switch (type)
                {
                case STGTY.Storage:
                    IStorage child_stg = stg.OpenStorage(stat[0].pwcsName, IntPtr.Zero, STGM.READ | STGM.SHARE_EXCLUSIVE, IntPtr.Zero, 0);
                    try
                    {
                        PopulateTree(child_stg, node);
                    }
                    finally
                    {
                        IS.Marshal.ReleaseComObject(child_stg);
                    }
                    node.ImageIndex         = 0;
                    node.SelectedImageIndex = 0;
                    break;

                case STGTY.Stream:
                    bytes = ReadStream(stg, stat[0].pwcsName, (int)stat[0].cbSize);
                    break;

                default:
                    break;
                }
                node.Tag = new STATSTGWrapper(EscapeStorageName(stat[0].pwcsName), stat[0], bytes);

                root.Nodes.Add(node);
            }
        }