# Listing Drives via IShellFolder and IEnumIDList

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

## 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);

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);
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

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633700
• Total Posts
3013426
×