internal int GetSelectedItemsCount()
        {
            int itemsCount = 0;

            IFolderView2 iFV2 = GetFolderView2();

            if (iFV2 != null)
            {
                try
                {
                    HResult hr = iFV2.ItemCount((uint)ShellViewGetItemObject.Selection, out itemsCount);

                    if (hr != HResult.Ok &&
                        hr != HResult.ElementNotFound &&
                        hr != HResult.Fail)
                    {
                        throw new CommonControlException(LocalizedMessages.ExplorerBrowserSelectedItemCount, hr);
                    }
                }
                finally
                {
                    Marshal.ReleaseComObject(iFV2);
                    iFV2 = null;
                }
            }

            return(itemsCount);
        }
Exemplo n.º 2
0
        internal int GetSelectedItemsCount()
        {
            int itemsCount = 0;

            IFolderView2 iFV2 = GetFolderView2();

            if (iFV2 != null)
            {
                try
                {
                    HRESULT hr = iFV2.ItemCount((uint)SVGIO.SVGIO_SELECTION, out itemsCount);

                    if (hr != HRESULT.S_OK &&
                        hr != HRESULT.E_ELEMENTNOTFOUND &&
                        hr != HRESULT.E_FAIL)
                    {
                        throw new COMException("unexpected error retrieving selected item count", (int)hr);
                    }
                }
                finally
                {
                    Marshal.ReleaseComObject(iFV2);
                    iFV2 = null;
                }
            }

            return(itemsCount);
        }