Platform SDK: DirectX

Setting the Loader's Search Directory

[C++]

By default, the loader looks for objects in the current directory unless a full path is specified in the wszFileName member of the DMUS_OBJECTDESC structure describing the object being sought. Using the IDirectMusicLoader::SetSearchDirectory method, you can set a different default path for the IDirectMusicLoader::GetObject and IDirectMusicLoader::EnumObject methods. This default path can apply to all objects, or only to objects of a certain class.

The following code example sets the search path for style files:

HRESULT mySetLoaderPath (
    IDirectMusicLoader *pILoader)    // Previously created
{
    return pILoader->SetSearchDirectory(
            CLSID_DirectMusicStyle,
            L"c:\\mymusic\\funky",
            FALSE);
}

Having called this function, the application can now load a style by file name, without including the full path, as in the following code example:

HRESULT myLoadStyleFromPath (
    IDirectMusicStyle **ppIStyle,    // Receives a pointer to a style
    IDirectMusicLoader *pILoader)    // Loader already created
{
    HRESULT hr;
    DMUS_OBJECTDESC Desc; 
 
    ZeroMemory(&Desc, sizeof(DMUS_OBJECTDESC);
    Desc.dwSize = sizeof(DMUS_OBJECTDESC);
    wcscpy(Desc.wszFileName, L"polka.sty");   // Short file name
    Desc.guidClass = CLSID_DirectMusicStyle;  // Object class
    Desc.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_FILENAME;
 
    hr = pILoader->GetObject(&Desc,
            IID_IDirectMusicStyle, (void **) ppIStyle);
    return hr;
}
[Visual Basic]

By default, the loader looks for file objects in the current directory unless a full path has been passed to the load method. Using the DirectMusicLoader.SetSearchDirectory method, you can set a different default path for the DirectMusicLoader.LoadBand, DirectMusicLoader.LoadCollection, DirectMusicLoader.LoadSegment, and DirectMusicLoader.LoadStyle methods.