明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2209|回复: 1

vba里编写语音报警问题

[复制链接]
发表于 2011-12-18 16:06:43 | 显示全部楼层 |阅读模式
各位好:
       我是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

发表于 2011-12-19 08:33:06 | 显示全部楼层
系统不支持罢了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 17:47 , Processed in 0.137096 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表