vba里编写语音报警问题
各位好:我是vb新手,有关vb里编写语音报警问题,请各位指点下。
我用的软件是ifix,编程环境是vba,在xp系统下编写的程序可以实现语音报警和报警声音取消,但在windows server2003环境下,该程序能实现语音报警,但不能实现报警声音取消。
请问代码部分需要做怎么样修改?API修改什么地方?
非常感谢!
以下是代码:
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Const SND_ASYNC = &H1 'play asynchronously
Private Const SND_LOOP = &H8 'loop the sound until next sndPlaySound
Private Const SND_MEMORY = &H4 'lpszSoundName points to a memory file
Private Const SND_NODEFAULT = &H2 'silence not default, if sound not found
Private Const SND_NOSTOP = &H10 'don't stop any currently playing sound
Private Const SND_NOWAIT = &H2000 'don't wait if the driver is busy
Private Const SND_PURGE = &H40 'purge non-static events for task
Private Const SND_SYNC = &H0 'play synchronously (default)
Dim SndFile As String
Private Sub AlarmSummaryOCX1_NewAlarm(strNode As String, strTag As String)
On Error Resume Next
Dim tNode0 As String, tTag0 As String
tNode0 = Trim(strNode)
tTag0 = Trim(strTag)
Do While InStr(1, tNode0, "", vbTextCompare) > 0
tNode0 = Replace(tNode0, "", " ", , , vbTextCompare)
Loop
Do While InStr(1, tTag0, "", vbTextCompare) > 0
tTag0 = Replace(tTag0, "", " ", , , vbTextCompare)
Loop
Dim tAlmStatus As String
Dim tNode() As String, tTag() As String
tNode = Split(tNode0, " ", , vbTextCompare)
tTag = Split(tTag0, " ", , vbTextCompare)
Dim i As Long
For i = 0 To UBound(tNode)
If Trim(tNode(i)) <> "" And Trim(tTag(i)) <> "" Then
tAlmStatus = Trim(ReadValue("FIX32." & Trim(tNode(i)) & "." & Trim(tTag(i)) & "." & "A_CUALM"))
If tAlmStatus = "HI" Or tAlmStatus = "HIHI" Or tAlmStatus = "CFN" Then
PlaySound SndFile, 0, SND_ASYNC + SND_LOOP + SND_NODEFAULT + SND_NOSTOP + SND_NOWAIT
Exit For
End If
End If
Next i
End Sub
Private Sub CFixPicture_Initialize()
SndFile = System.ProjectPath
SndFile = SndFile & "\ALM\alarm.wav"
AlarmSummaryOCX1.CheckForNewAlarms = True
AlarmSummaryOCX1.AlarmHornEnabled = False
End Sub
'确认报警,取消声音,下面这段代码在xp下可以取消声音,server2003环境下取消不了声音
Private Sub CommandButton1_Click()
AlarmSummaryOCX1.AckAllAlarms
PlaySound vbNull, vbNull, vbNull
End Sub
系统不支持罢了
页:
[1]