Results 1 to 9 of 9

Thread: Opening external programs

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    11

    Unhappy

    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

  2. #2
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Cool 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"

  3. #3
    Guest
    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

  4. #4
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Wink 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"

  5. #5
    Guest
    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.

  6. #6
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Thumbs up 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"

  7. #7
    New Member
    Join Date
    Apr 2002
    Location
    New York/ Hawaii
    Posts
    5

    Question 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?

  8. #8
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    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

  9. #9
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943

    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
  •  



Click Here to Expand Forum to Full Width