Maybe I don't understand the code correctly. But PopulateTreeNodeWithFiles and PopulateWithRoot are the two methods of TCustomShellTreeview and TCustomShellListView which call GetFilesInDir. They use a local stringlist for GetFilesInDir; the stringlist has OwnsObjects=true and is destroyed at the end of these methods. Therefore, if the FileItems were only attached to the treenodes/listitems they would be gone here. This can't be.
Yes, you are right.
The TShellTreeNode class just has some extra fields, none of them a class or pointer as I mistakenly believed. My mistake.
It's a long time since I wrote that.
To be on the safe side an exception should be raised if the stringlist passed to GetFilesInDir has OwnsObjects = false.
At the time I considered setting OwnsObjects to True inside TCustomShellTreeView.GetFilesInDir, but that cannot be done, since the parameter is defined as being a TStrings, which does not have this property!
So, neither can an exception be raised (nor can my previous suggestion be implemented).
The behaviour is well documented in the code.
Hoovering the mouse over a call to TCustomShellTreeView.GetFilesInDir however does not show this warning in the hint, whereas it propery display all the other text that is in the comments right above it's definition.
Maybe the proper xml file (in docs/xml) should be updated?
Bart