Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

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?
0
pig_dog
Asked:
pig_dog
  • 2
1 Solution
 
vinnyd79Commented:
Private Sub Command1_Click()
Dim AppPath As String

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

Shell AppPath & "Winamp.exe", vbNormalFocus

End Sub
0
 
vinnyd79Commented:
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
0
 
SmashmadCommented:
'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
0
 
pig_dogAuthor Commented:
Thankyou For TAKING THE TIME TO HELP ME, enjoy your points.

Thnks againg - Works a treat.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now