CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 1999
    Posts
    1

    launching URLs from a VB app, is it possible ?

    i am interested in launching a webpage via visual basic app
    i am using visual basic 4.0 professional edition
    thanks


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: launching URLs from a VB app, is it possible ?

    use the ShellExecute API:

    ShellExecute(..., "yourpage.htm",...,"open", SW_SHOWNORMAL)



    ...will launch the browser and display the given HTML page or ASP.


  3. #3
    Guest

    Re: launching URLs from a VB app, is it possible ?

    Code:
    'DECLARATION:
    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
    
    'WEBPAGE:
    Private Sub Command1_Click()
    
        Dim lRet As Long
        Dim sText As String
    
        sText = "http://www.codeguru.com"
        lRet = ShellExecute(hwnd, "open", sText, vbNull, vbNull, SW_SHOWNORMAL)
    
        If lRet >= 0 And lRet <= 32 Then
            MsgBox "Unable to start Web browser !"
        End If
    
    End Sub
    
    'EMAIL:
    Private Sub Command2_Click()
    
        Dim lRet As Long
        Dim sText As String
    
        sText = "mailto:webmaster@codeguru.com"
        lRet = ShellExecute(hwnd, "open", sText, vbNull, vbNull, SW_SHOWNORMAL)
    
        If lRet >= 0 And lRet <= 32 Then
            MsgBox "Unable to start email client!"
        End If
    
    End Sub
    
    'ANY FILE:
    Private Sub Command3_Click()
    
        Dim lRet As Long
        Dim sText As String
    
        sText = "c:\test.txt"
        lRet = ShellExecute(hwnd, "open", sText, vbNull, vbNull, SW_SHOWNORMAL)
    
        If lRet >= 0 And lRet <= 32 Then
            MsgBox "Unable to open file!"
        End If
    
    End Sub
    [Cimperiali colorized for better reading]
    Last edited by Cimperiali; December 7th, 2002 at 05:33 AM.

  4. #4
    Join Date
    Jul 2006
    Posts
    2

    Question Re: launching URLs from a VB app, is it possible ?

    It's fine, but I have a dude:

    If I have 2 or more internet browser instance's , how choose other than last. ???

    I supuse what it must work with lpParameters, re-knowing number instance and comparing path.

    Any knows how do it ??.

  5. #5
    Join Date
    Aug 2000
    Location
    South East England
    Posts
    86

    Exclamation Re: launching URLs from a VB app, is it possible ?

    I have used the above code;
    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
    in Visual Basic 5 for meny years.

    I have just updated from Visual Basic 5 to Visual Basic 2005 Express Edition and tois code no longer works.

    I use it to load a help/information file from my application.

    Dose anybody know any new code?

    Mark Agius, Sussex, England.

  6. #6
    Join Date
    Sep 2006
    Posts
    392

    Re: launching URLs from a VB app, is it possible ?

    Try this
    Code:
    Imports System.Diagnostics
    Public Module modmain
       Sub Main()
          Dim NewProcess as Process = new Process
          NewProcess.Start("C:\MyApplication.exe")
       End Sub
    End Module
    And call this module in button click event

  7. #7
    Join Date
    Jul 2007
    Posts
    28

    Re: launching URLs from a VB app, is it possible ?

    Code:
    'DECLARATION:
    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
    
    'WEBPAGE:
    Private Sub Command1_Click()
    
        Dim lRet As Long
        Dim sText As String
    
        sText = "http://www.codeguru.com"
        lRet = ShellExecute(hwnd, "open", sText, vbNull, vbNull, SW_SHOWNORMAL)
    
        If lRet >= 0 And lRet <= 32 Then
            MsgBox "Unable to start Web browser !"
        End If
    
    End Sub
    
    'EMAIL:
    Private Sub Command2_Click()
    
        Dim lRet As Long
        Dim sText As String
    
        sText = "mailto:webmaster@codeguru.com"
        lRet = ShellExecute(hwnd, "open", sText, vbNull, vbNull, SW_SHOWNORMAL)
    
        If lRet >= 0 And lRet <= 32 Then
            MsgBox "Unable to start email client!"
        End If
    
    End Sub
    
    'ANY FILE:
    Private Sub Command3_Click()
    
        Dim lRet As Long
        Dim sText As String
    
        sText = "c:\test.txt"
        lRet = ShellExecute(hwnd, "open", sText, vbNull, vbNull, SW_SHOWNORMAL)
    
        If lRet >= 0 And lRet <= 32 Then
            MsgBox "Unable to open file!"
        End If
    
    End Sub
    [Cimperiali colorized for better reading]
    does shellexecute work in the same way in vb6?

  8. #8
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: launching URLs from a VB app, is it possible ?

    that is vb6 code. the above 2 posts were hijacked from the OP, much like you did.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

Featured