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

问题描述 投票:0回答:1

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

在 RDP 客户端中启用声音,并从客户端中的 RDP 应用程序发出 Windows 声音。

应用用途

??chr(7)

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

如何从VFP应用程序发出蜂鸣声或其他声音?可以使用一些 API 调用或者可以从 FoxPro 播放某些文件吗?

audio windows-server visual-foxpro rdp foxpro
1个回答
0
投票

可以使用一些API调用或者可以从FoxPro播放一些文件吗?

你可以尝试一下Win32API函数,比如

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
© www.soinside.com 2019 - 2024. All rights reserved.