如何从 FoxPro RDP 应用程序发出哔哔声

How to beep from FoxPro RDP application

提问人:Andrus 提问时间:9/27/2023 更新时间:9/27/2023 访问量:60

问:

Visual FoxPro 应用程序正在与 Windows 11 远程桌面客户端一起运行 Microsoft Hyper-V 服务器 2019。

在 RDP 客户端中启用声音,在客户端中启用来自 RDP apper 的 Windows 声音。

应用用途

??chr(7)

哔哔声的命令。此声音不会出现在客户端中。如果应用程序在本地运行, chr(7) 会导致 Windows 默认声音。

如何从 VFP 应用程序发出哔哔声或发出其他声音?可以使用某些 API 调用,或者是否可以播放 FoxPro 中的某些文件?

音频 Windows-Server Visual-FoxPro RDP FoxPro

评论


答:

3赞 Stefan Wuebbe 9/27/2023 #1

可以使用某些 API 调用,或者是否可以播放 FoxPro 中的某些文件?

您可以尝试 Win32API 函数 ,例如sndPlaySound

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

评论

1赞 Andrus 9/28/2023
我发现从FoxPro运行带有内容的.bat文件可以播放声音COPY ..\algus\chr7.txt CON timeout 2