Platform SDK: DirectX

DirectMusicPerformance.Init

The DirectMusicPerformance.Init method initializes the performance and associates it with a DirectSound object. This method should be called only once, before any other methods are called on the performance.

object.Init(DirectSound As DirectSound, hwnd As Long)

Parameters

object
Object expression that resolves to a DirectMusicPerformance object.
DirectSound
Existing DirectSound object, or Nothing if you want DirectMusic to create the object.
hwnd
Window handle to be used for the creation of DirectSound. This parameter can be 0, in which case the foreground window is used. See Remarks.

Error Codes

If the method fails, it raises an error, and Err.Number can be set to one of the following values:

DMUS_E_ALREADY_INITED
DMUS_E_OUTOFMEMORY

Remarks

There should be only one DirectSound object per process. If your application uses a DirectSound object for playing waves, it must pass in that object here.

The hwnd parameter is significant only if DirectSound is Nothing. If a DirectSound object is created separately by the application and passed to this method, the application is responsible for setting the window handle in a call to DirectSound.SetCooperativeLevel.

Do not 0 pass as hwnd because the application window might not be in the foreground when the method is called. In general, the top-level application window handle should be passed to DirectMusicPerformance.Init, DirectSound.SetCooperativeLevel, and DirectDraw7.SetCooperativeLevel.

The performance must be terminated by using the DirectMusicPerformance.CloseDown method before being released.