How can I open external programs from a toolbar using Visual Basic 6?
External programs are like WinAMP, Microsoft Internet Explorer, Microsoft Word...etc. Pretty much anything that isn't Visual Basic 6 itself.
Please hurry...I need this quickly!!!
Printable View
How can I open external programs from a toolbar using Visual Basic 6?
External programs are like WinAMP, Microsoft Internet Explorer, Microsoft Word...etc. Pretty much anything that isn't Visual Basic 6 itself.
Please hurry...I need this quickly!!!
example:Code:x = shell("Path & app",windowstate)
hope this helpsCode:x = Shell("c:\notepad.exe", vbMaximizedFocus)
geoff_xrx, why do you have it returning a value?
Or cyrus_hunter, you could use the ShellExecute api function.Code:Shell "c:\myprogram.exe", vbNormalFocus
Code: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 Const SW_SHOWNORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
Private Const SW_Hide = 0
ShellExecute Me.hwnd, vbNullString, "C:\MyFile.exe", _
vbNullString, "c:\", SW_SHOWNORMAL
its a bad habit....
It still works and the returned value isn't needed...its just the first way I learned it so it has kinda stuck...
just like x = msgbox("hello") and msgbox "hello".
he he
Your right geoff_xrx.
x = Shell("myprogram.exe")
^was the first way I learned too.
Than I realized, what is x suppose to be or be doing?
And then I changed it :rolleyes:.
I guess it's okay.
The only problem with Shell is that it can only launch executable files.
With command lines.
For example, Notepad:
You cannot do:Code:Shell "Notepad C:\MyFile.txt", vbNormalFocus
Or you will get an error.Code:Shell "C:\MyFile.txt", vbNormalFocus
Whereas, with the ShellExecute api function, it will load the file with the default application that extension is using. --Better understanding for cyrus_hunter as well.
Good to know...I have never had the need to use the default app...but I will copy the code and save it...Just in case.
Thanks!
[/SIZE]:confused:
this is the code i am using:
Private Sub Form_Load()
Form1.Hide
X = Shell("C:\Program Files\Diablo II\Diablo II.exe", vbNormalFocus)
If X Then Shell("C:\Program Files\Windows Media Player\wmplayer.exe", vbMinimizedFocus)
End Sub
I want D2 and Media player open so i can listen to music while i play.
i get the Compile error: syntax error message and i dont have the help file or the api.
my question is: how do i fix this error?
just a note for anyone who cares, u can also use shellexecute to open a web page, just pass the url instead of the filename...Quote:
Originally posted by Matthew Gates
Whereas, with the ShellExecute api function, it will load the file with the default application that extension is using. --Better understanding for cyrus_hunter as well.
the problem is w/ the lineQuote:
Originally posted by sonyc27
[/SIZE]:confused:
this is the code i am using:
Private Sub Form_Load()
Form1.Hide
X = Shell("C:\Program Files\Diablo II\Diablo II.exe", vbNormalFocus)
If X Then Shell("C:\Program Files\Windows Media Player\wmplayer.exe", vbMinimizedFocus)
End Sub
I want D2 and Media player open so i can listen to music while i play.
i get the Compile error: syntax error message and i dont have the help file or the api.
my question is: how do i fix this error?
if x then shell....
just put shell("C:\Program Files\Windows Media Pplayer\wmplayer.exe", vbminimizedfocus)