1

I found this code here on stack overflow and modified it to return a List instead of an arraylist. The function is called whenever I press a key, and while this function gets called alright, SelectedItems() just seems to be empty every time even though I have stuff highlighted on the desktop. I tried it in an explorer window as well with the same result. Does anyone know why it is returning nothing? The other people on stackoverflow seemed to be able to make it work what is wrong with mine?

 public List<string> GetShellItems()
    {
        List<string> selected = new List<string>();
        foreach (SHDocVw.InternetExplorer window in new SHDocVw.ShellWindows())
        {
            filename = Path.GetFileNameWithoutExtension(window.FullName).ToLower();
            if (filename.ToLowerInvariant() == "explorer")
            {
                Shell32.FolderItems items = ((Shell32.IShellFolderViewDual2)window.Document).SelectedItems();
                foreach (Shell32.FolderItem item in items)
                {
                    selected.Add(item.Path);
                }
            }
        }
        return selected;

    }
Bob Saget
  • 67
  • 2
  • 8

0 Answers0