The IDirectSound::SetCooperativeLevel method sets the cooperative level of the application for this sound device.
HRESULT SetCooperativeLevel(
HWND hwnd,
DWORD dwLevel
);
If the method succeeds, the return value is DS_OK.
If the method fails, the return value may be one of the following error values:
DSERR_ALLOCATED |
DSERR_INVALIDPARAM |
DSERR_UNINITIALIZED |
DSERR_UNSUPPORTED |
The application must set the cooperative level by calling this method before its buffers can be played. The recommended cooperative level is DSSCL_PRIORITY; use other priority levels when necessary. For additional information, see Cooperative Levels.
The hwnd parameter should be the top-level application window handle. If you are also using DirectDraw, it must be the same handle passed to the IDirectDraw4::SetCooperativeLevel method.
If your application cannot easily supply a window handle, you can obtain one by using the following code:
HWND hWnd = GetForegroundWindow();
if (hWnd == NULL)
{
hWnd = GetDesktopWindow();
}
Windows NT/2000: Requires Windows NT 4.0 SP3 or later.
Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
Header: Declared in dsound.h.
Import Library: Use dsound.lib.
IDirectSound::Compact, IDirectSoundBuffer::GetFormat, IDirectSoundBuffer::GetVolume, IDirectSoundBuffer::Lock, IDirectSoundBuffer::Play, IDirectSoundBuffer::Restore, IDirectSoundBuffer::SetFormat