DirectX SDK

IDirectMusicLoader::ScanDirectory

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

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

Parameters

rguidClass
Reference to (C++) or address of (C) the identifier of the class of objects.
pwzFileExtension
File extension for the type of file to look for—for example, L"sty" for style files. Use L"*" to look in files with any or no extension.
pwzScanFileName
Name of an optional storage file to store and retrieve 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 following error values:

DMUS_E_NOT_FOUND
E_FAIL
E_OUTOFMEMORY
E_POINTER
REGDB_E_CLASSNOTREG

Remarks

The IDirectMusicLoader::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. Once it has been so 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).

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

GUID_DirectMusicAllTypes is not a valid value for rguidClass.

Requirements

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in dmusici.h.

See Also

Scanning a Directory for Objects