all groups > vb.net > february 2005 >
You're in the

vb.net

group:

Process.Start for .WAV file



Process.Start for .WAV file genojoe
2/14/2005 10:07:02 PM
vb.net: The following command plays a wave file and opens a media application:

Process.Start("C:\Windows\Media\tada.wav")

I would like to play a wav file without opening the default media player.
How do I do that?
Re: Process.Start for .WAV file Imran Koradia
2/15/2005 1:48:22 AM
You can P/Invoke on the PlaySound API:

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal lpszName As String, ByVal hModule As Integer, _
ByVal dwFlags As Integer) As Integer

Const SND_SYNC As Integer = &H0 ' play synchronously
Const SND_ASYNC As Integer = &H1 ' play asynchronously
Const SND_FILENAME As Integer = &H20000 ' lpszName is a file name
Const SND_PURGE As Integer = &H40 ' purge non-static events for task

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim RetStart As Integer = _
PlaySound("D:\WINDOWS\ring.wav", 0, SND_ASYNC Or SND_FILENAME)
Dim RetStop As Integer = _
PlaySound(Nothing, 0, SND_PURGE)
End Sub

Various other flag values and what they mean can be found here (where
PlaySound has been explained):
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_playsound.asp


However, I'm not sure if one can play any other file types other than .wav
files with PlaySound. I could be wrong though - didn't have the time to test
it out.

hope that helps..
Imran.

[quoted text, click to view]

Re: Process.Start for .WAV file Herfried K. Wagner [MVP]
2/15/2005 2:05:13 PM
"genojoe" <genojoe@discussions.microsoft.com> schrieb:
[quoted text, click to view]

See:

<URL:http://foren.activevb.de/cgi-bin/foren/view.pl?id=45731085811d16c70727d9e1cb36431d&forum=6&msg=14002&root=14001&page=1>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Re: Process.Start for .WAV file Cor Ligthert
2/15/2005 2:21:13 PM
Herfried,

A nice site,

Cor

AddThis Social Bookmark Button