DirectX SDK

Scanning a Directory for Objects

[Visual Basic]

This topic pertains only to applications written in C++.

[C++]

The IDirectMusicLoader::ScanDirectory method scans the current search directory for objects of a given 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 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 an Object from a File.)

Note  It is always a good idea to call IDirectMusicLoader::ScanDirectory before loading any objects. Even though you might be loading objects explicitly by file name, those objects could contain references to other objects not identified by file name, and the loader would not be able to find these referenced objects if ScanDirectory was not called on every directory in which 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 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. Nevertheless, you can implement a cache file now, and it will speed up performance under future versions.

For an example, see Enumerating Objects.