Microsoft DirectX 8.1 (Visual Basic)

Step 2: Load a File

The DirectMusicLoader8 object created in the preceding step can be used throughout the lifetime of the application to load sound data from files.

To get the data, the loader needs to know where to find it. Although a full path can be provided each time a file is loaded, it is more convenient to establish a default directory. Do this by using the DirectMusicLoader8.SetSearchDirectory method. The sample application uses the path returned by its FindMediaDir function. This function finds the directory where the sample file is located. The loader could subsequently load any file from this directory without being given more than the name.

dml.SetSearchDirectory FindMediaDir("sample.sgt", True)

The loader then loads the file and returns it as a DirectMusicSegment8 object:

Set seg = dml.LoadSegment("sample.sgt")

Next: Step 3: Play the File