procedure TMyTreeView.EnumerateFolder ( ShellFolder: IShellFolder; mask : DWORD;node : tTreeNode );
var
flags : DWORD;
EnumList : IEnumIdList;
FQ_PIDL, PidlPath, list : PItemIdList;
fetched : ULONG;
FolderName:
string;
attr : ULONG;
HexAttr :
string;
ImageIndex : integer;
begin
items.BeginUpdate;
PidlPath := node.data;
fSortFolder := true;
flags := SHCONTF_FOLDERS
or SHCONTF_INCLUDEHIDDEN;
try
if (( ShellFolder.EnumObjects (
handle, flags, EnumList )) = NOERROR)
and Assigned(EnumList)
then
begin
while (EnumList.Next ( 1, list, fetched ) = NOERROR)
do
begin
// ImageIndex := -1;
FolderName := GetDirectory ( ShellFolder, list, SHGDN_INFOLDER);
//SHGDN_NORMAL );
attr := ALL_ATRIBUTES;
ShellFolder.GetAttributesOf ( 1, list, attr );
HexAttr := IntToHex (attr, 4);
if ( attr
and mask > 0 )
then
try
FQ_PIDL := CombinePidls ( PidlPath, list );
fFullPidlPathList.add ( FQ_PIDL );
ImageIndex := GetNormalIcon ( FQ_PIDL );
node := items.AddChildObject ( node, FolderName, FQ_PIDL );
if ( attr
and SFGAO_HASSUBFOLDER > 0 )
then
Node.HasChildren := true;
Node.ImageIndex := ImageIndex;
Node.SelectedIndex := GetSelectedIcon ( FQ_PIDL );
if FCheck
then SwitchStateIndex(node,attr);
// image with hand-icon
if ( SFGAO_SHARE
and attr ) > 0
then
Node.OverlayIndex := 0;
node := node.parent;
except
on e :
exception do
ShowMessage(e.
Message);
end;
ShellMalloc.free ( list );
end;
// end while do ..
end;
except
// showmessage('ENUM FEHLER');
//beep;
end;
items.EndUpdate;
end;