Microsoft DirectX 9.0

Scanning a Directory for Objects

The IDirectMusicLoader8::ScanDirectory method scans the current search directory for objects of a specified class. You can further narrow the search by providing a subclass and a file extension other than "*".

The method compiles a list of all matching files and uses the IDirectMusicObject8::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 an Object from a File.

Note   If you are working with DirectMusic Producer content, it is always a good idea to call 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 in which the objects might reside.

If you include a pointer to a string in the pwszScanFileName parameter of the ScanDirectory method, the results of the scan are cached in a file by that name, to speed up subsequent scans. When a cache file is available, the method updates object information only for files whose time stamps or sizes have changed.

Note   In the current version of DirectMusic, ScanDirectory does not use the cache file. However, implementing a cache file does no harm.

For an example, see Enumerating Objects.