ficheros de audio .wav
Clase separada
Public Class ClsReproducirMusica
<Runtime.InteropServices.DllImport("kernel32. Dll", SetLastError:=True, CharSet:=Runtime.InteropServices.CharSet. Auto)> _
Public Shared Function GetShortPathName(ByVal longPath As String, _
<Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType. LPTStr)> _
ByVal ShortPath As System.Text.StringBuilder, _
<Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType. U4)> _
ByVal bufferSize As Integer) As Integer
End Function
Declare Function mciExecute Lib "winmm. Dll" (ByVal lpstrCommand As String) As Integer
End Class
en el form..
button_clic
ClsReproducirMusica. MciExecute("Play " & ShortPathName(soncf). ToString)
end sub
Function ShortPathName(ByVal Path As String) As String
Dim sb As New System.Text.StringBuilder(1024)
Dim tempVal As Integer = ClsReproducirMusica. GetShortPathName(Path, sb, 1024)
If tempVal <> 0 Then
Dim Result As String = sb. ToString()
Return Result
Else
Throw New Exception("Error en la function: ShortPathName")
End If
End Function