Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Play a WAV file Sound

API Functions

How to Play a WAV file Sound

by  wgcs  Posted    (Edited  )
You can take the goofy way:

Code:
SET BELL TO "c:\source\Sounds\blip.wav"
? chr(7)
SET BELL TO

or you can take the windows API route:

Code:
PlaySound('c:\source\Sounds\blip.wav')


PROCEDURE PlaySound( tcWavFile, tnFlags )
  * play synchronously (default) */
  #define SND_SYNC            0x0000  
  * play asynchronously */
  #define SND_ASYNC           0x0001  
  * silence (!default) if sound not found */
  #define SND_NODEFAULT       0x0002  
  * pszSound points to a memory file */
  #define SND_MEMORY          0x0004  
  * loop the sound until next sndPlaySound */
  #define SND_LOOP            0x0008  
  * don't stop any currently playing sound */
  #define SND_NOSTOP          0x0010  
  
  * don't wait if the driver is busy */
  #define SND_NOWAIT	      0x00002000
  * name is a registry alias */
  #define SND_ALIAS           0x00010000
  * alias is a predefined ID */
  #define SND_ALIAS_ID	      0x00110000
  * name is file name */
  #define SND_FILENAME        0x00020000
  * name is resource name or atom */
  #define SND_RESOURCE        0x00040004
  *#if(WINVER >= 0x0400)
  * purge non-static events for task */
  #define SND_PURGE           0x0040  
  * look for application specific association */
  #define SND_APPLICATION     0x0080  
  *#endif /* WINVER >= 0x0400 */

  DECLARE INTEGER PlaySound IN WinMM.dll AS PS_API ;
    STRING @ pszSound, INTEGER HMODULE_hmod, LONG DWORD_fdwSound  
  LOCAL lnFlags
  lnFlags = iif( vartype(tnFlags)='N', tnFlags, SND_ASYNC+SND_FILENAME )
  PS_API(tcWavFile,0,lnFlags)
ENDPROC
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top