Office中国论坛/Access中国论坛
标题: [求助]输入的数字发声的函数(api),被卡巴6弹出警告 [打印本页]
作者: tz-chf 时间: 2007-1-13 18:05
标题: [求助]输入的数字发声的函数(api),被卡巴6弹出警告
两种写法都被测出警告,跳过才行。交给客户有点麻烦。
Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" _
(ByVal filename As String, ByVal snd_async As Long) As Long
Function PlaySound(sWavFile As String)
' Purpose: Plays a sound.
' Argument: the full path and file name.
If apisndPlaySound(sWavFile, 1) = 0 Then
MsgBox "The Sound Did Not Play!"
End If
End Function
调用方法:PlaySound "文件名.WAV"
Private Const SND_APPLICATION = &H80
Private Const SND_ALIAS = &H10000
Private Const SND_ALIAS_ID = &H110000
Private Const SND_ASYNC = &H1
Private Const SND_LOOP = &H8
Private Const SND_MEMORY = &H4
Private Const SND_NODEFAULT = &H2
Private Const SND_NOSTOP = &H10
Private Const SND_NOWAIT = &H2000
Private Const SND_PURGE = &H40
Private Const SND_RESOURCE = &H40004
Private Const SND_SYNC = &H0
Private Declare Function PlaySound Lib "winmm.dll" Alias "laySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Sub Command0_Click()
Me.子窗体.Requery
If Me.子窗体.Form.CurrentRecord = 0 Then MsgBox "对不起,没有此记录"
PlaySound "C:\WINDOWS\MEDIA\TADA.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
End If
End Sub
[此贴子已经被作者于2007-1-13 11:54:38编辑过]
作者: andymark 时间: 2007-1-14 05:54
不会是和某个病毒的特征码相似吧
作者: tz-chf 时间: 2007-1-14 06:58
而且卡巴还把这句代码都显示出来让你看,真是利害。
作者: tz-chf 时间: 2007-1-15 01:15
如果选择“中止”的话,全完蛋——所有变量都空了。
烦烦烦
作者: fan0217 时间: 2007-1-15 03:04
用这个试试,http://www.office-cn.net/forum.php?mod=viewthread&tid=40497&replyID=&skin=1,卡巴不会反对的。
'===============================================================================
'-函数名称: MySpeak
'-功能描述: 朗读文本内容
'-输入参数说明: 参数1: 必选 strSpeak As String 朗读的文本内容
' 参数2: 可选 IntRate As Integer 设置朗读的速度 范围:-10到+10
' 参数3: 可选 intVolume As Integer 设置朗读的音量 范围:0到100
' 参数4: 可选 intVoiceID As Integer 朗读者ID
'-返回参数说明:
'-使用语法示例: Call MySpeak ("中华人民共和国")
'-参考: 网上资料
'-使用注意: 需要引用 Microsoft Speech Object Library
'-兼容性:
'-作者: fan0217@163.com
'-更新日期: 2006-05-25
'===============================================================================
Private Function MySpeak(strSpeak As String, _
Optional intRate As Integer = 0, _
Optional intVolume As Integer = 50, _
Optional intVoiceID As Integer = 0) As Boolean
On Error GoTo Err_MySpeak
Dim oVoise As New SpeechLib.SpVoice
Dim intTotalSpeech As Integer
intTotalSpeech = oVoise.GetVoices.Count '获取朗读者的数量
If intTotalSpeech = 0 Then Exit Function
'设置朗读者
If intVoiceID > intTotalSpeech - 1 Then intVoiceID = 0
Set oVoise.Voice = oVoise.GetVoices.Item(intVoiceID)
'设置朗读速度
If intRate > 10 Then intRate = 10
If intRate < -10 Then intRate = -10
oVoise.Rate = intRate
'设置朗读音量
If intVolume > 100 Then intVolume = 100
If intVolume < 0 Then intVolume = 0
oVoise.Volume = intVolume
oVoise.Speak strSpeak
MySpeak = True
Exit_MySpeak:
Exit Function
Err_MySpeak:
MySpeak = False
MsgBox Err.Description, 64, "fan0217"
Resume Exit_MySpeak
End Function
[此贴子已经被作者于2007-1-14 19:07:39编辑过]
作者: tz-chf 时间: 2007-1-15 05:14
它念英文,输单的人会晕的。
没办法,让用户自己添加到排除列表就行了。
[此贴子已经被作者于2007-1-14 21:23:24编辑过]
作者: tz-chf 时间: 2007-1-16 19:53
用VB运行同样的代码,一点事都没有。确实根本性的不同。
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) |
Powered by Discuz! X3.3 |