DirectX SDK |
This tutorial pertains only to applications written in C++. See DirectMusic Visual Basic Tutorials.
In order to load any object from disk, you first need to create the DirectMusicLoader object. This is done just as for any other COM object, as shown in the following sample function:
IDirectMusicLoader* CreateLoader(void) { IDirectMusicLoader* pLoader; if (FAILED(CoCreateInstance( CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC, IID_IDirectMusicLoader, (void**)&pLoader ))) { pLoader = NULL; } return pLoader; }
You'll use this function to initialize a global variable:
IDirectMusicLoader* g_pLoader = CreateLoader(); if (g_pLoader == NULL) { // Failure -- loader not created }