- Option Explicit 
- 'Función Api GetShortPathName para obtener _ 
- los paths de los archivos en formato corto 
- Private Declare Function GetShortPathName _ 
-     Lib "kernel32" _ 
-     Alias "GetShortPathNameA" ( _ 
-         ByVal lpszLongPath As String, _ 
-         ByVal lpszShortPath As String, _ 
-         ByVal lBuffer As Long) As Long 
-   
- 'Función Api mciExecute para reproducir los archivos de música 
- Private Declare Function mciExecute _ 
-     Lib "winmm.dll" ( _ 
-         ByVal lpstrCommand As String) As Long 
- Dim ret As Long, path As String 
-   
- 'Le pasamos el comando Play 
- Private Sub Command1_Click() 
-     ejecutar ("Play ") 
-     Habilitar "Play" 
- End Sub 
-   
- Private Sub Command2_Click() 
-     'Le pasamos el comando Stop 
-     ejecutar ("Stop ") 
-     Habilitar "Stop" 
- End Sub 
-   
- 'Le pasamos el comando Pause 
- Private Sub Command3_Click() 
-     ejecutar ("Pause ") 
-     Habilitar "Pause" 
- End Sub 
-   
- 'Le pasamos el comando Close a MciExecute para cerrar el dispositivo 
- Private Sub Form_Unload(Cancel As Integer) 
-     mciExecute "Close All" 
- End Sub 
-   
- 'Botón para abrir seleccionar los archivos de audio 
- Private Sub Command4_Click() 
-     With CommonDialog1 
-         .Filter = "Archivos Wav|*.wav|Archivos Mp3|*.mp3|Archivos MIDI|*.mid" 
-         .ShowOpen 
-         If .FileName = "" Then 
-             Habilitar "Iniciar" 
-             Exit Sub 
-         Else 
-             'Le pasamos a la sub que obtiene con _ 
-             el Api GetShortPathName el nombre corto del archivo 
-             PathCorto .FileName 
-             Label1 = .FileName 
-             'cerramos todo 
-             mciExecute "Close All" 
-             'Para Habilitar y deshabilitar botones 
-             Habilitar "Stop" 
-         End If 
-     End With 
- End Sub 
-   
- 'Sub que obtiene el path corto del archivo a reproducir 
- Private Sub PathCorto(archivo As String) 
- Dim temp As String * 250 'Buffer 
-     path = String(255, 0) 
-     'Obtenemos el Path corto 
-     ret = GetShortPathName(archivo, temp, 164) 
-     'Sacamos los nulos al path 
-     path = Replace(temp, Chr(0), "") 
- End Sub 
-   
- 'Procedimiento que ejecuta el comando con el Api mciExecute 
- '************************************************************ 
- Private Sub ejecutar(comando As String) 
-     If path = "" Then MsgBox "Error", vbCritical: Exit Sub 
-     'Llamamos a mciExecute pasandole un string que tiene el comando y la ruta 
-   
-     mciExecute comando & path 
-   
- End Sub 
-   
- Private Sub Form_Load() 
-     Command1.Caption = "Play >>" 
-     Command2.Caption = "Stop ||||" 
-     Command3.Caption = "Pause ||" 
-     Command4.Caption = ":::: Abrir archivo de música ::::" 
-     Habilitar "Iniciar" 
-     Label1 = "": Label1.AutoSize = True 
- End Sub 
-   
- Private Sub Habilitar(Accion As String) 
-     Select Case Accion 
-         Case "Iniciar" 
-             Command1.Enabled = False 
-             Command2.Enabled = False 
-             Command3.Enabled = False 
-         Case "Play" 
-             Command1.Enabled = False 
-             Command2.Enabled = True 
-             Command3.Enabled = True 
-         Case "Stop" 
-             Command1.Enabled = True 
-             Command2.Enabled = False 
-             Command3.Enabled = False 
-         Case "Pause" 
-             Command1.Enabled = True 
-             Command2.Enabled = True 
-             Command3.Enabled = False 
-     End Select 
- End Sub 
-   
-