The IDirectMusicLoader::ScanDirectory method scans the current search directory for objects of a given class. You can further narrow down the search by providing a subclass and a file extension other than "*".
The method compiles a list of all matching files and uses the IDirectMusicObject::ParseDescriptor method to extract the GUID and the name of the object. These identifiers are retained in an internal database so that the application can subsequently load objects by GUID or name rather than by file name. (See Loading Objects.)
Note It is always a good idea to call IDirectMusicLoader::ScanDirectory before loading any objects. Even though you may be loading objects explicitly by file name, those objects might contain references to other objects not identified by file name, and the loader will not be able to find these referenced objects if ScanDirectory has not been called on every directory where the objects might be.
If you include a pointer to a string in the pwszScanFileName parameter of the ScanDirectory method, the results of the scan will be cached in a file by that name in order to speed up subsequent scans. When a cache file is available, the method updates object information only for files whose timestamps or sizes have changed.
Note In the current version of DirectMusic, ScanDirectory does not actually use the cache file. Nonetheless you can implement a cache file now and it will speed up performance under future versions.
For an example, see Enumerating Objects.