Board index » delphi » SoundPlaySnd

SoundPlaySnd

Does anyone know how to test for a sound card before
using the SoundPlaySnd function? If there is no sound card
present, the program runs okay anyway, but on exiting there is
a GDI error.

Thanks for any help!

Fairbro

 

Re:SoundPlaySnd


Quote
> Does anyone know how to test for a sound card before
> using the SoundPlaySnd function? If there is no sound card
> present, the program runs okay anyway, but on exiting there is
> a GDI error.

Use the waveOutGetNumDevs function in MMSystem, e.g.:

if waveOutGetNumDevs = 0 then { no WAV sound drivers installed }
        ...
else
        ...

Don't forget to add MMsystem in your Uses clause.

--

|  Dave O'Brien - Watcom International - dobr...@watcom.com
|     http://www.cgl.uwaterloo.ca/~gmgrimsh/dobrien.html
+----------------------------------------------------------
| "The patience of the bricklayer
|  Is assumed in the dream of the architect"
|                                           - Gael Turnbull

Re:SoundPlaySnd


In article u...@news.smart.net, Jim Fairbrother <fairbroth...@smart.net> () writes:

Quote
>Does anyone know how to test for a sound card before
>using the SoundPlaySnd function? If there is no sound card
>present, the program runs okay anyway, but on exiting there is
>a GDI error.

>Thanks for any help!

>Fairbro

Try:

  uses MMSystem;

    numMCIOutputDevices:= waveOutGetNumDevs;

You can also use waveOutGetDevCaps to get the capabilities of the device.

Best regards,

Michael Vincze
vin...@ti.com

Other Threads