Obtaining an IDirectSound3DListener Interface Pointer
To obtain a pointer to an IDirectSound3DListener interface, you must first create a primary 3D sound buffer. Do this by using the IDirectSound::CreateSoundBuffer method, specifying the DSBCAPS_CTRL3D flag in the dwFlags member of the accompanying DSBUFFERDESC structure. Then, use the IDirectSoundBuffer::QueryInterface method on the resulting buffer to obtain a pointer to an IDirectSound3DListener interface for that buffer, as shown in the following example:
// lpDsbPrimary was created by using DSBCAPS_CTRL3D.
hr = lpDsbPrimary->QueryInterface(IID_IDirectSound3DListener,
&lpDs3dListener);
if(SUCCEEDED(hr)) {
// Perform 3D operations.
.
.
.
}