/// <summary>
        /// Gets the items in the ExplorerBrowser as an IShellItemArray
        /// </summary>
        /// <returns></returns>
        internal IShellItemArray GetItemsArray()
        {
            IShellItemArray iArray = null;
            IFolderView2    iFV2   = GetFolderView2();

            if (iFV2 != null)
            {
                try
                {
                    Guid    iidShellItemArray = new Guid(ShellIIDGuid.IShellItemArray);
                    object  oArray            = null;
                    HResult hr = iFV2.Items((uint)ShellViewGetItemObject.AllView, ref iidShellItemArray, out oArray);
                    if (hr != HResult.Ok &&
                        hr != HResult.Fail &&
                        hr != HResult.ElementNotFound &&
                        hr != HResult.InvalidArguments)
                    {
                        throw new CommonControlException(LocalizedMessages.ExplorerBrowserViewItems, hr);
                    }

                    iArray = oArray as IShellItemArray;
                }
                finally
                {
                    Marshal.ReleaseComObject(iFV2);
                    iFV2 = null;
                }
            }
            return(iArray);
        }
예제 #2
0
        /// <summary>
        /// Gets the items in the ExplorerBrowser as an IShellItemArray
        /// </summary>
        /// <returns></returns>
        internal IShellItemArray GetItemsArray()
        {
            IShellItemArray iArray = null;
            IFolderView2    iFV2   = GetFolderView2();

            if (iFV2 != null)
            {
                try
                {
                    Guid    iidShellItemArray = new Guid(ShellIIDGuid.IShellItemArray);
                    object  oArray            = null;
                    HRESULT hr = iFV2.Items((uint)SVGIO.SVGIO_ALLVIEW, ref iidShellItemArray, out oArray);
                    if (hr != HRESULT.S_OK &&
                        hr != HRESULT.E_FAIL &&
                        hr != HRESULT.E_ELEMENTNOTFOUND &&
                        hr != HRESULT.E_INVALIDARG)
                    {
                        throw new COMException("unexpected error retrieving view items", (int)hr);
                    }

                    iArray = oArray as IShellItemArray;
                }
                finally
                {
                    Marshal.ReleaseComObject(iFV2);
                    iFV2 = null;
                }
            }
            return(iArray);
        }