Here is a sample in C++, which displays just disk drives:
void CFullTreeViewDlg::OnFilteringSftdirectory1( LPDISPATCH FAR* Folder, BOOL FAR* RemoveFolder) { ISftDirectoryFolderPtr pFolder = *Folder; if (pFolder->GetType() >= typeSftDirectory_Computer_Drive35 && pFolder->GetType() <= typeSftDirectory_Computer_Other) { ; // OK } else { *RemoveFolder = VARIANT_TRUE; } }
If a folder with invalid shortcuts is displayed, SftDirectory will seem to load slowly as the Windows Shell retrieves non-existent icon images for the invalid shortcuts. For example, if invalid shortcuts are present on the desktop, it may seem that forms load slowly. Removing the invalid shortcuts will correct the problem. These symptoms are only present if the Files property is set to True.
The Desktop shown in the directory list is not the same as the Desktop directory. The physical location is usually something like C:\Documents and Settings\username\Desktop. The Desktop directory is a physical location with a path. You can retrieve its location using the Windows SHGetFolderPath API. The Desktop shown in the directory list is not a real location, it is a purely virtual folder. For that reason the Path property will always be empty (as there is no physical location). ItemIDList is also empty as it is not a locatable item. It is only shown for the SftDirectory styles (ControlStyle) styleSftDirectoryTreeView and styleSftDirectoryComboBoxTreeView. The Desktop is always the first item, making it easily recognizable by its position (its index is 0) or if you only have a folder object (SftDirectoryFolder) you can test it like this:
Dim AFolder As SftDirectoryFolder Set AFolder = SftDirectory1.Selection(0) ' any folder If AFolder Is SftDirectory1.FolderList(0) Then ... it's the Desktop End If