Visual FoxPro application is running with Windows 11 Remote Desktop Client in Microsoft Hyper-V server 2019.
Sounds are enabled in RDP client and Windows sounds from RDP apper in client.
Application uses
??chr(7)
command for beep. This sound does not appear in client. If application is running locally, chr(7) causes windows default sound.
How to beep or make other sound from VFP Application? Can some API call used or is it possible to play some file from FoxPro?
Can some API call used or is it possible to play some file from FoxPro?
You can try the Win32API function sndPlaySound
, like
LOCAL lcWavFile1, lcWavFile2
*!* lcWavFile1 = GETFILE('wav')
lcWavFile1 = EVL(m.lcWavFile1, ADDBS(GETENV("windir")) + 'Media\Windows Notify.wav')
*!* lcWavFile2 = GETFILE('wav')
lcWavFile2 = EVL(m.lcWavFile2, ADDBS(GETENV("windir")) + 'Media\tada.wav')
IF !EMPTY(m.lcWavFile1)
? PlayWAV(m.lcWavFile1)
ENDIF
IF !EMPTY(m.lcWavFile2)
? PlayWAV(m.lcWavFile2, 1)
ENDIF
FUNCTION PlayWAV(tcWavFile, tnUserFlag)
* http://support.microsoft.com/kb/86281
* tcWavFile = path to wav file to play
* tnUserFlag = Integer controling play mode
* 0 Synchronously
* specifies that the sound is played synchronously and
* the function does not return until the sound ends.
* 1 Asynchronously
* specifies that the sound is played asynchronously and
* the function returns immediately after beginning the sound.
* 2 NoDefault
* specifies that if the sound cannot be found, the function
* returns silently without playing the default sound.
* 8 Loop
* specifies that the sound will continue to play continuously
* until wPlayWav() is called again with the tcWavFile parameter set to null.
* You must also specify the Loop flag to loop sounds.
* 16 NoStop
* specifies that if a sound is currently playing, the function will
* immediately return False without playing the requested sound.
* RETURNS TRUE (1) if sound is played, otherwise returns FALSE (0)
Assert ( VarType(m.tcWavFile)='C' And File(m.tcWavFile,1) )
Assert ( PCount()<2 Or VarType(m.tnUserFlag)='N' )
Declare Integer sndPlaySound ;
In winMM.DLL ;
String cSoundName, Integer uFlags
Local lnFlag, lnReturn
lnFlag = IIF( VarType(m.tnUserFlag)='N', m.tnUserFlag, 0 )
lnReturn = sndPlaySound(m.tcWavFile,m.lnFlag)
Return (m.lnReturn = 1)
ENDFUNC