Iterating through files is the old-fashioned way. Modern programs are supposed to iterate through the shell name space using IShellFolder. Unfortunately, IShellFolder seems specifically designed to test the limits of Hardcore programming. I spent many hours with the inadequate documentation and C-oriented design and finally got the Visual Basic code working a few days before this book shipped.
I could probably do another chapter this long on IShellFolder, but you’ll have to be satisfied with the Cliff’s Notes version. So let’s start at the beginning—with a question: What is a folder? It’s a container in the shell namespace that contains some sort of items. The most common kind of folder is a file system directory filled with file items, but any group of objects can be defined as a folder. The Printers folder, for example, contains printers rather than files. The Desktop folder on my system contains My Computer, the Recycle Bin, and My Briefcase. Theoretically, you can define your own folders. Some applications define ZIP or CAB files as folders containing their compressed contents as items. But we’ll have enough trouble walking through the shell namespace without worrying about extending it.