Microsoft DirectX 9.0


The ScanDirectory method searches a directory or disk for all files of a specified class type and file name extension. For each file found, it calls the IDirectMusicObject8::ParseDescriptor method to extract the GUID and name of the object. This information is stored in an internal database. After a directory has been scanned, all files of the requested type become available for enumeration through the IDirectMusicLoader8::EnumObject method; in addition, an object can be retrieved by using IDirectMusicLoader8::GetObject, even without a file name.


HRESULT ScanDirectory(
  REFGUID rguidClass,
  WCHAR* pwzFileExtension,
  WCHAR* pwzScanFileName



Reference to (C++) or address of (C) the identifier of the class of objects. For a list of standard loadable classes, see IDirectMusicLoader8.


File name extension for the type of file to look for. Use L"*" to look in files with any or no extension. (See Remarks.)


Name of a file to use for cached file information. This file is created by the first call to ScanDirectory and used by subsequent calls. Pass NULL if a cache file is not wanted.

Return Values

If the method succeeds, the return value is S_OK, or S_FALSE if no files were found.

If it fails, the method can return one of the error values shown in the following table.

Return code


The IDirectMusicLoader8::SetSearchDirectory method must be called first to set the location to search.

The scanned information can be stored in a cache file defined by pwzScanFileName. After it has been stored, subsequent calls to ScanDirectory are much quicker because only files that have changed are scanned (the cache file stores the file size and date for each object, so it can tell if a file has changed).

GUID_DirectMusicAllTypes is not a valid value for rguidClass.

If the file type has more than one possible extension, call ScanDirectory once for each file name extension.


  Header: Declared in dmusici.h.

See Also