Link to home
Start Free TrialLog in
Avatar of pig_dog
pig_dog

asked on

How Can I launch another application in Visual Basic?

i am making a winamp controller app and i want winamp.exe in the same directory as my plugin to load up.

How Can i do this?

Please Help

Or Can i make a button to launch the application?
ASKER CERTIFIED SOLUTION
Avatar of vinnyd79
vinnyd79

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vinnyd79
vinnyd79

you could also use shellexecute api. It will open anyfile with it's default application.

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Command1_Click()
Call ShellExecute(hwnd, "Open", ("C:\Somefile.mp3"), "", App.Path, 1)
End Sub
'You can open winamp, and specify a file to open, or append a file to the playlist


you can use this functions as you want..
Private Sub Command1_Click()

call Winamp 'abre el winamp
call openFile("c:\My First Mp3 file.mp3") 'opens that file
call Enquee("c:\MyMp3.mp3") 'adds MyMp3.mp3 to the playlist

End Sub


'TO OPEN WINAMP ONLY
Private Sub Winamp()
Dim NewPath As String

If Right(App.path, 1) <> "\" Then
   NewPath = App.path & "\"
Else
   NewPath = App.path
End If
Shell (NewPath & "winamp.exe")

End Sub


'TO ENQUEE A FILE
Private Sub Enquee(file As String)
Dim NewPath As String

If Right(App.path, 1) <> "\" Then
   NewPath = App.path & "\"
Else
   NewPath = App.path
End If

Shell (NewPath & "winamp.exe /ADD " & Chr(34) & file & Chr(34))

End Sub


'TO OPEN A FILE
Private Sub openFile(file As String)
Dim NewPath As String

If Right(App.path, 1) <> "\" Then
   NewPath = App.path & "\"
Else
   NewPath = App.path
End If

Shell (NewPath & "winamp.exe " & Chr(34) & file & Chr(34))

End Sub
Avatar of pig_dog

ASKER

Thankyou For TAKING THE TIME TO HELP ME, enjoy your points.

Thnks againg - Works a treat.