The IDirectMusicPerformance::Init method associates the performance with a DirectMusic object and a DirectSound object.
HRESULT Init(
IDirectMusic** ppDirectMusic,
LPDIRECTSOUND pDirectSound,
HWND hWnd
);
If the variable contains NULL, a DirectMusic object is created and the interface pointer returned.
If ppDirectMusic is NULL, a DirectMusic object is created and used internally by the performance.
See Remarks.
This parameter is ignored if pDirectSound is not NULL, in which case the application is responsible for setting the window handle in a call to IDirectSound::SetCooperativeLevel.
If the method succeeds, the return value is S_OK.
If it fails, the method may return one of the following error values:
DMUS_E_ALREADY_INITED |
E_OUTOFMEMORY |
E_POINTER |
This method should be called only once, and must be called before the performance can play.
There are three different ways of associating a DirectMusic object with the performance:
The performance must be terminated by using the IDirectMusicPerformance::CloseDown method before being released.
You can pass NULL in the hWnd parameter in order to pass the current foreground window handle to DirectSound. However, it is not wise to assume that the application window will be in the foreground during initialization. In general, the top-level application window handle should be passed to DirectMusic, DirectSound, and DirectDraw. See the Remarks for IDirectSound::SetCooperativeLevel.
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.
Creating the Performance, Integrating DirectMusic and DirectSound