Bueno , ahi me quedo funcionando
Código:
Function PathTo(strFile As String) As String
Dim x As Integer
Dim strDirs As String
Dim strDir As String
Dim strEntry As String
strDirs = "c:\" & vbNullChar
Do While Len(strDirs)
x = InStr(strDirs, vbNullChar)
strDir = Left$(strDirs, x - 1)
strDirs = Mid$(strDirs, x + 1)
If Len(Dir$(strDir & strFile)) Then
PathTo = strDir & Dir$(strDir & strFile)
Exit Function
End If
strEntry = Dir$(strDir & "*.*", vbDirectory)
Do While Len(strEntry)
If (GetAttr(strDir & strEntry) And vbDirectory) Then
If strEntry <> "." And strEntry <> ".." Then
strDirs = strDirs & strDir & strEntry & "\" & vbNullChar
End If
End If
strEntry = Dir$
Loop
Loop
PathTo = ""
End Function
Public Sub ExecuteFile(FilePath As String)
On Error GoTo error
Dim Ret As Long
Ret = Shell("rundll32.exe url.dll ,FileProtocolHandler " & (FilePath))
Exit Sub
error: MsgBox Err.Description, vbExclamation, "Error"
End Sub
Private Sub Command1_Click()
PathTo ("msnmsgr.exe")
Text1.Text = PathTo("msnmsgr.exe")
'##########################################
ExecuteFile PathTo("msnmsgr.exe")
End Sub
Ahora, una pregunta: porque si quiero buscar el archivo micancionfavorita.mp3 me da error ??
sera que solo sirve para archivos.exe ??