| DirectX SDK | 
The information in this topic pertains only to applications written in C and C++. See DirectSound Visual Basic Tutorials.
Before closing the application you must shut down the capture system. This is a simple matter of releasing all the objects. You must release the IDirectSoundNotify interface before releasing the capture buffer.
void CleanupDSoundCapture(void)
{
    if (lpdsNotify) 
        IDirectSoundNotify_Release(lpdsNotify);    
    if (lpdscb) 
        IDirectSoundCaptureBuffer_Release(lpdscb);
    if (lpdsc) 
        IDirectSoundCapture_Release(lpdsc);
}