el tema de que se corta el sonido en otras ventanas, lo podes solucionar con la api
GetForegroundWindow y un Timer, algo asi:
Código vb:
Ver originalOption Explicit
Private Declare Function GetForegroundWindow Lib "User32" () As Long
Dim DX As DirectX8
Dim DS As DirectSound8
Dim dsToneBuffer As DirectSoundSecondaryBuffer8
Dim desc As DSBUFFERDESC
Const SRATE = 44100
Private Sub Form_Load()
Set DX = New DirectX8
Set DS = DX.DirectSoundCreate("")
DS.SetCooperativeLevel Me.hWnd, DSSCL_NORMAL
Timer1.Enabled = True
Timer1.Interval = 1000
desc.fxFormat.nFormatTag = WAVE_FORMAT_PCM
desc.fxFormat.nSize = 0
desc.fxFormat.lExtra = 0
desc.fxFormat.nChannels = 1
desc.fxFormat.lSamplesPerSec = SRATE
desc.fxFormat.nBitsPerSample = 16
desc.fxFormat.nBlockAlign = 2
desc.fxFormat.lAvgBytesPerSec = 2 * SRATE
desc.lFlags = DSBCAPS_STATIC Or DSBCAPS_CTRLVOLUME Or DSBCAPS_CTRLFREQUENCY Or DSBCAPS_CTRLPAN
desc.lBufferBytes = 2 * 1 * SRATE
Set dsToneBuffer = DS.CreateSoundBufferFromFile("C:\WINDOWS\media\Entrada de Windows XP.wav", desc)
dsToneBuffer.SetVolume -4000 ' aca pones el volumen, fijarse en un tutorial caules son los valores aceptados por DirectX
dsToneBuffer.Play DSBPLAY_LOOPING
End Sub
Private Sub Timer1_Timer()
Dim vHwnd As Long
vHwnd = GetForegroundWindow
If vHwnd > 0 Then DS.SetCooperativeLevel vHwnd, DSSCL_NORMAL
End Sub
saludos.