|
-
Nov 20th, 2000, 10:29 AM
#1
Thread Starter
New Member
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!!!
- Cyrus
"I'm covered in dirt, I'm covered in sweat, hell, I'm covered in fur!" - Celcia Maricriel, Those Who Hunt Elves
-
Nov 20th, 2000, 10:45 AM
#2
no problem...
Code:
x = shell("Path & app",windowstate)
example:
Code:
x = Shell("c:\notepad.exe", vbMaximizedFocus)
hope this helps
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Nov 20th, 2000, 10:50 AM
#3
geoff_xrx, why do you have it returning a value?
Code:
Shell "c:\myprogram.exe", vbNormalFocus
Or cyrus_hunter, you could use the ShellExecute api function.
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
-
Nov 20th, 2000, 10:54 AM
#4
bad habit
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
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Nov 20th, 2000, 11:07 AM
#5
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 .
I guess it's okay.
The only problem with Shell is that it can only launch executable files.
With command lines.
For example, Notepad:
Code:
Shell "Notepad C:\MyFile.txt", vbNormalFocus
You cannot do:
Code:
Shell "C:\MyFile.txt", vbNormalFocus
Or you will get an error.
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.
-
Nov 20th, 2000, 11:16 AM
#6
cool
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!
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 8th, 2002, 03:57 PM
#7
New Member
X
[/SIZE]
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?
-
Apr 8th, 2002, 03:59 PM
#8
Frenzied Member
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.
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...
Government is another way to say better…than…you.
It’s like ice but no pick, a murder charge that won’t stick,
it’s like a whole other world where you can smell the food,
but you can’t touch the silverware.
Huh, what luck. Fascism you can vote for.
Humph, isn’t that sweet?
And we’re all gonna die some day, because that’s the American way
-Stone Sour
-
Apr 8th, 2002, 04:01 PM
#9
Frenzied Member
Re: X
Originally posted by sonyc27
[/SIZE]
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?
the problem is w/ the line
if x then shell....
just put shell("C:\Program Files\Windows Media Pplayer\wmplayer.exe", vbminimizedfocus)
Government is another way to say better…than…you.
It’s like ice but no pick, a murder charge that won’t stick,
it’s like a whole other world where you can smell the food,
but you can’t touch the silverware.
Huh, what luck. Fascism you can vote for.
Humph, isn’t that sweet?
And we’re all gonna die some day, because that’s the American way
-Stone Sour
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|