Microsoft DirectX 9.0


The SetCooperativeLevel method sets the cooperative level of the application for this sound device.


HRESULT SetCooperativeLevel(
  HWND hwnd,
  DWORD dwLevel



Handle to the application window.


Requested level. Specify one of the values shown in the following table.


Value Description
DSSCL_EXCLUSIVE For DirectX 8.0 and later, has the same effect as DSSCL_PRIORITY. For previous versions, sets the application to the exclusive level. This means that when it has the input focus, the application will be the only one audible; sounds from applications with the DSBCAPS_GLOBALFOCUS flag set will be muted. With this level, it also has all the privileges of the DSSCL_PRIORITY level. DirectSound will restore the hardware format, as specified by the most recent call to the IDirectSoundBuffer8::SetFormat method, after the application gains the input focus.
DSSCL_NORMAL Sets the normal level. This level has the smoothest multitasking and resource-sharing behavior, but because it does not allow the primary buffer format to change, output is restricted to the default 8-bit format.
DSSCL_PRIORITY Sets the priority level. Applications with this cooperative level can call the IDirectSoundBuffer8::SetFormat and IDirectSound8::Compact methods.
DSSCL_WRITEPRIMARY Sets the write-primary level. The application has write access to the primary buffer. No secondary buffers can be played. This level cannot be set if the DirectSound driver is being emulated for the device; that is, if the IDirectSound8::GetCaps method returns the DSCAPS_EMULDRIVER flag in the DSCAPS structure.

Return Values

If the method succeeds, the return value is DS_OK.

If the method fails, the return value may be one of the error values shown in the following table.

Return code


The application must set the cooperative level by calling this method before its buffers can be played. The recommended cooperative level is DSSCL_PRIORITY.

Do not call this method if any buffers are locked.


  Header: Declared in dsound.h.

See Also