|
Imports System.Runtime.InteropServices
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form Vom Windows Form Designer generierter Code
<DllImport("winmm.dll", EntryPoint:="sndPlaySoundA")> _
Public Shared Function PlayWav (ByVal lpszName As String, _
ByVal dwFlags As Integer) As Integer
End Function
Private Const SND_ASYNC = &H1
Private Const SND_LOOP = &H8
Private Const SND_MEMORY = &H4
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim nRet As Integer
If TextBox1.Text = "" Then
SoundDateiWaehlen()
If TextBox1.Text = "" Then Exit Sub
End If
Dim fi As New FileInfo(TextBox1.Text)
If fi.Exists = False Then
MsgBox("Falsche Pfadangabe" & vbNewLine & "Wählen Sie " & _
"eine Wav-Datei, um Sound abspielen zu können!", _
MsgBoxStyle.Exclamation, "Falsche Pfadangabe")
SoundDateiWaehlen()
If fi.Exists = False Then Exit Sub
End If
nRet = PlayWav(TextBox1.Text, SND_ASYNC)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Dim nRet As Integer
If TextBox1.Text = "" Then
SoundDateiWaehlen()
If TextBox1.Text = "" Then Exit Sub
End If
Dim fi As New FileInfo(TextBox1.Text)
If fi.Exists = False Then
MsgBox("Falsche Pfadangabe" & vbNewLine & "Wählen Sie " & _
"eine Wav-Datei, um Sound abspielen zu können!", _
MsgBoxStyle.Exclamation, "Falsche Pfadangabe")
SoundDateiWaehlen()
If fi.Exists = False Then Exit Sub
End If
nRet = PlayWav(TextBox1.Text, SND_LOOP Or SND_ASYNC)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button3.Click
Dim nRet As Integer
nRet = PlayWav(TextBox1.Text, _
SND_LOOP Or SND_ASYNC Or SND_MEMORY)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click
Me.Close()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button5.Click
SoundDateiWaehlen()
End Sub
Sub SoundDateiWaehlen()
With OpenFileDialog1
Dim sPath As String
sPath = Environment.SystemDirectory.Substring( _
0, Environment.SystemDirectory.LastIndexOf("\")) & _
"\Media"
.InitialDirectory = sPath
.Title = "Wählen Sie eine Wav-Datei"
.Filter = "Wav-Dateien (*.wav)|*.wav"
.RestoreDirectory = True
If .ShowDialog() = DialogResult.OK Then
TextBox1.Text = .FileName
End If
End With
End Sub
End Class
|
|