Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal Name As String, ByVal hMod As Long, _
ByVal Flags As Long) As Long
PlaySound "C:\InStructurez.wav", 0, SND_FILENAME Or SND_ASYNC
Const SND_SYNC = &H0 ' play synchronously
Const SND_ASYNC = &H1 ' play asynchronously
Const SND_FILENAME = &H20000 ' name is file name
Const SND_RESOURCE = &H40004 ' name is resource name or atom
Const SND_SYNC = &H0 ' play synchronously
Const SND_ASYNC = &H1 ' play asynchronously
Const SND_FILENAME = &H20000 ' name is file name
Const SND_RESOURCE = &H40004 ' name is resource name or atom
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal Name As String, ByVal hMod As Long, _
ByVal Flags As Long) As Long
Private Sub Form_Load()
PlaySound "C:\InStructurez.wav", 0, SND_FILENAME Or SND_ASYNC
End Sub
Declare Auto Function PlaySound Lib "winmm.dll" (ByVal Name _
As String, ByVal hMod As Integer, ByVal Flags As Integer) As Integer
Public Const SND_SYNC = &H0 ' play synchronously
Public Const SND_ASYNC = &H1 ' play asynchronously
Public Const SND_FILENAME = &H20000 ' name is file name
Public Const SND_RESOURCE = &H40004 ' name is resource name or atom
PlaySound("C:\InStructurez.wav", Nothing, SND_FILENAME Or SND_ASYNC)
Public Class SoundClass
Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name _
As String, ByVal hmod As Integer, ByVal flags As Integer) As Integer
' name specifies the sound file when the SND_FILENAME flag is set.
' hmod specifies an executable file handle.
' hmod must be Nothing if the SND_RESOURCE flag is not set.
' flags specifies which flags are set.
' The PlaySound documentation lists all valid flags.
Public Const SND_SYNC = &H0 ' play synchronously
Public Const SND_ASYNC = &H1 ' play asynchronously
Public Const SND_FILENAME = &H20000 ' name is file name
Public Const SND_RESOURCE = &H40004 ' name is resource name or atom
Public Sub PlaySoundFile(ByVal filename As String)
' Plays a sound from filename.
PlaySound(filename, Nothing, SND_FILENAME Or SND_ASYNC)
End Sub
End Class
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim SoundInst As New SoundClass()
SoundInst.PlaySoundFile("C:\ringout.wav")
End Sub
[System.Runtime.InteropServices.DllImport("winmm.DLL",
EntryPoint = "PlaySound", SetLastError = true)]
private static extern bool PlaySound(string Name,
int hMod, int Flags);
const int SND_SYNC = 0x0000; // play synchronously
const int SND_ASYNC = 0x0001; // play asynchronously
const int SND_FILENAME = 0x00020000; // name is file name
const int SND_RESOURCE = 0x00040004; // name is resource name or atom
PlaySound(@"C:\InStructurez.wav", 0, SND_SYNC);
using System.Windows.Forms;
namespace WinSound
{
public partial class Form1 : Form
{
private TextBox textBox1;
private Button button1;
public Form1() //constructor
{
InitializeComponent();
}
[System.Runtime.InteropServices.DllImport("winmm.DLL",
EntryPoint = "PlaySound", SetLastError = true)]
private static extern bool PlaySound(string szSound, System.IntPtr hMod,
PlaySoundFlags flags);
[System.Flags]
public enum PlaySoundFlags : int
{
SND_SYNC = 0x0000,
SND_ASYNC = 0x0001,
SND_NODEFAULT = 0x0002,
SND_LOOP = 0x0008,
SND_NOSTOP = 0x0010,
SND_NOWAIT = 0x00002000,
SND_FILENAME = 0x00020000,
SND_RESOURCE = 0x00040004
}
private void button1_Click (object sender, System.EventArgs e)
{
OpenFileDialog dialog1 = new OpenFileDialog();
dialog1.Title = "Browse to find sound file to play";
dialog1.InitialDirectory = @"c:\";
dialog1.Filter = "Wav Files (*.wav)|*.wav";
dialog1.FilterIndex = 2;
dialog1.RestoreDirectory = true;
if(dialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = dialog1.FileName;
PlaySound (dialog1.FileName, new System.IntPtr(),
PlaySoundFlags.SND_SYNC);
}
}
}
}
Dim PlaySoundTest As New System.Media.SoundPlayer("C:\InStructurez.wav")
PlaySoundTest.Play()
System.Media.SoundPlayer PlaySoundTest =
new System.Media.SoundPlayer(@"C:\InStructurez.wav");
PlaySoundTest.Play();
Dim PlaySoundTest As New _
Microsoft.DirectX.AudioVideoPlayback.Audio("C:\InStructurez.wav")
PlaySoundTest.Play()
Microsoft.DirectX.AudioVideoPlayback.Audio PlaySoundTest =
new Microsoft.DirectX.AudioVideoPlayback.Audio(@"C:\InStructurez.wav");
PlaySoundTest.Play();
BOOL PlaySound(LPCSTR pszSound,HMODULE hmod,DWORD fdwSound);
#include
int main(void)
{
PlaySound("myfile.wav",NULL,SND_FILENAME|SND_ASYNC);
return 0;
}
Add code here...