Jump to content
  • Advertisement
Sign in to follow this  
RonHiler

Listing Drives via IShellFolder and IEnumIDList

This topic is 4743 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I'm working on creating a drive crawler that I can use in my DirectX programs. The crawler is mostly done, but I'm having one problem. If you open up a standard drive crawler (say in Word or Excel by hitting the "Open" button), at the top is a drop-down box that is titled "Look In:", (it starts off with Desktop, then My Computer, then lists all the drives including and subfolders down to the current directory, and so on). Now, I don't necessarily need (at this point) to exactly mimic all that stuff, right now I would be happy just getting a drive listing. I may want to, in the future, expand it later, but I'll cross that bridge when I come to it :) Unfortunately, I'm having trouble wrapping my head around all these obscure shell commmands. Using various examples I've found, I've managed to get the box to show certain things, but I'm stuck on getting the drive listings. Here is what I have. I'm going to take out the error code for brevity:
void DirectoryCrawlerClass::PopulateLookInBox()
    {
    LPSHELLFOLDER DesktopFolder;
    LPSHELLFOLDER SubItem;
    LPITEMIDLIST pidlDrives;
    SHFILEINFO FileInfo;

    if (!SUCCEEDED(SHGetMalloc(&ShellMalloc)))
        {
        }

    if (!SUCCEEDED(SHGetDesktopFolder(&DesktopFolder)))
        {
        }

    if (!SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidlDrives)))
        {
        }

    SHGetFileInfo((LPCSTR)(pidlDrives), 0, &FileInfo, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME | SHGFI_ATTRIBUTES | SHGFI_PIDL);
    LookInBox->AddSelection(FileInfo.szDisplayName);

    if (SUCCEEDED(DesktopFolder->BindToObject(pidlDrives, NULL, IID_IShellFolder, (void**)(&SubItem))))
        {
        PopulateLookInBoxSubItems(SubItem, pidlDrives);
        SubItem->Release();
        }

    ShellMalloc->Free(pidlDrives);
    DesktopFolder->Release();
    ShellMalloc->Release();
    LookInBox->SetSelectedMember(0);
    }

(where ShellMalloc is a class member variable, and LookIn is another class member variable that is a class of its own)
//---------------------------------------------------------------------------
void DirectoryCrawlerClass::PopulateLookInBoxSubItems(LPSHELLFOLDER ShellFolder, LPITEMIDLIST ItemList)
    {
    LPENUMIDLIST IDList;
    LPITEMIDLIST CurrentItem;
    SHFILEINFO FileInfo;

    if (SUCCEEDED(ShellFolder->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &IDList)))
        {
        while (IDList->Next(1, &CurrentItem, NULL) == NOERROR)
            {
            SHGetFileInfo((LPCSTR)(CurrentItem), 0, &FileInfo, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME | SHGFI_PIDL);
            LookInBox->AddSelection(FileInfo.szDisplayName);
            ShellMalloc->Free(CurrentItem);
            }
        IDList->Release();
        }
    }

What I get in my LookIn drop-down box is the "My Computer" folder (this is coming from the first routine), and nothing else. I'm not entirely sure where to go from here, any suggestions? Ron

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!