如何在.net中播放声音? [英] How to play sound in .net?
本文介绍了如何在.net中播放声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我以前使用以下代码在VB6中播放声音:
公共声明功能sndPlaySound32 Lib" winmm的.dll" Alias" sndPlaySoundA"
_
(ByVal lpszSoundName As String,ByVal uFlags As Long)As Long
调用sndPlaySound32(" c:\ WinNt \ Media \ ing.wav",0)
但是,.net不承认呼叫,并且生成语法错误。我只是想知道如何在.net中播放声音?
谢谢!
CM
Hi,
I used to use the following code to play sound in VB6:
Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA"
_
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
call sndPlaySound32("c:\WinNt\Media\ding.wav", 0)
However, .net don''t recognize "call", and generate a syntax error. I just
wonder how to play sound in .net?
Thanks!
CM
推荐答案
试试这个:
''// Win32API
''//两个整数args和return最初是Longs - .NET Integer = vb6
Long
声明函数PlaySound Lib" winmm.dll" _
Alias" PlaySoundA" (ByVal lpszName As String,_
ByVal hModule As Integer,_
ByVal dwFlags As Integer)As Integer
Friend Sub PlayAudio(ByVal FileName As String)
''//调用win32api函数播放音频(wav)文件提醒
Dim retval As Integer
retval = PlaySound(FileName,0,1)
''最后一个参数是SND_SYNC为整数
''设置为0的值播放声音同步(等到声音结束之前
下一个播放)
''值设置为1播放声音异步(不等待播放下一个
声音)
End Sub
" CM" <厘米*** @ hotmail.com>在留言中写道
news:u6 ************** @ TK2MSFTNGP10.phx.gbl ...
try this:
''//Win32API
''//Both integer args and return were originally Longs - .NET Integer = vb6
Long
Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Integer, _
ByVal dwFlags As Integer) As Integer
Friend Sub PlayAudio(ByVal FileName As String)
''//call win32api function to play audio (wav) file alert
Dim retval As Integer
retval = PlaySound(FileName, 0, 1)
''last param is SND_SYNC as integer
''value set to 0 plays sound Synchronously (waits until sound ends before
playing next)
''value set to 1 plays sound Asynchronously (does not wait to play next
sound)
End Sub
"CM" <cm***@hotmail.com> wrote in message
news:u6**************@TK2MSFTNGP10.phx.gbl...
>
我曾经使用下面的代码在VB6中播放声音:
Public Declare Function sndPlaySound32 Lib" winmm.dll"别名
" sndPlaySoundA" _
(ByVal lpszSoundName As String,ByVal uFlags As Long)长期
调用sndPlaySound32(" c:\ WinNt \ Media \ ing.wav", 0)
然而,.net不识别call,并生成语法错误。我只是想知道如何在.net中播放声音?
谢谢!
CM
Hi,
I used to use the following code to play sound in VB6:
Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
call sndPlaySound32("c:\WinNt\Media\ding.wav", 0)
However, .net don''t recognize "call", and generate a syntax error. I just
wonder how to play sound in .net?
Thanks!
CM
试试这个:
''// Win32API
''//整数args和return最初都是Longs - .NET整数= vb6
长
声明函数PlaySound Lib" winmm.dll" _
Alias" PlaySoundA" (ByVal lpszName As String,_
ByVal hModule As Integer,_
ByVal dwFlags As Integer)As Integer
Friend Sub PlayAudio(ByVal FileName As String)
''//调用win32api函数播放音频(wav)文件提醒
Dim retval As Integer
retval = PlaySound(FileName,0,1)
''最后一个参数是SND_SYNC为整数
''设置为0的值播放声音同步(等到声音结束之前
下一个播放)
''值设置为1播放声音异步(不等待播放下一个
声音)
End Sub
" CM" <厘米*** @ hotmail.com>在留言中写道
news:u6 ************** @ TK2MSFTNGP10.phx.gbl ...
try this:
''//Win32API
''//Both integer args and return were originally Longs - .NET Integer = vb6
Long
Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Integer, _
ByVal dwFlags As Integer) As Integer
Friend Sub PlayAudio(ByVal FileName As String)
''//call win32api function to play audio (wav) file alert
Dim retval As Integer
retval = PlaySound(FileName, 0, 1)
''last param is SND_SYNC as integer
''value set to 0 plays sound Synchronously (waits until sound ends before
playing next)
''value set to 1 plays sound Asynchronously (does not wait to play next
sound)
End Sub
"CM" <cm***@hotmail.com> wrote in message
news:u6**************@TK2MSFTNGP10.phx.gbl...
>
我曾经使用下面的代码在VB6中播放声音:
Public Declare Function sndPlaySound32 Lib" winmm.dll"别名
" sndPlaySoundA" _
(ByVal lpszSoundName As String,ByVal uFlags As Long)长期
调用sndPlaySound32(" c:\ WinNt \ Media \ ing.wav", 0)
然而,.net不识别call,并生成语法错误。我只是想知道如何在.net中播放声音?
谢谢!
CM
Hi,
I used to use the following code to play sound in VB6:
Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
call sndPlaySound32("c:\WinNt\Media\ding.wav", 0)
However, .net don''t recognize "call", and generate a syntax error. I just
wonder how to play sound in .net?
Thanks!
CM
非常感谢!
CM
Thank you very much!
CM
这篇关于如何在.net中播放声音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文