Results 1 to 2 of 2

Thread: Starting default browser...again

  1. #1

    Thread Starter
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Unhappy

    Uhm, I know this is somewhere on the net, but I can't seem to find it now. How can I determine (and start) the default browser on a user's PC?

    r0ach™
    Don't forget to rate the post

  2. #2
    Guest
    There are two ways of doing this:

    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

    (1):
    Function ShellToBrowser%(frm As Form, ByVal url$, ByVal WindowStyle%)
    'ShellToBrowser(Me,"http://www.site.com",0)
    Dim api%
    api% = ShellExecute(frm.hwnd, "open", url$, "", App.Path, WindowStyle%)
    'Check return value
    If api% < 31 Then
    'error code - see api help for more info
    MsgBox App.Title & " had a problem running your web browser. You should check that your browser is correctly installed. (Error #" & Format$(api%) & ")", 48, "Browser Unavailable"
    ShellToBrowser% = False
    ElseIf api% = 32 Then
    'no file association
    MsgBox App.Title & " could not find a file association for " & url$ & " on your system. You should check that your browser is correctly installed and associated with this type of file.", 48, "Browser Unavailable"
    ShellToBrowser% = False
    Else
    'It worked!
    ShellToBrowser% = True
    End If
    End Function

    Sub OpenDefaultBrowser(frm As Form, url As String, Style As Integer)
    'OpenDefaultBrowser(Me,"http://www.site.com",0)
    opn% = ShellToBrowser(frm, url, Style)
    End Sub

    OR

    (2):
    Public Sub wwwaddress(Address As String)
    '// open up the default web browser and send it to a web page address
    On Error Resume Next
    Dim ReturnVal As Long
    ReturnVal& = Shell("Start.exe " & Address$, 1)
    End Sub


    Hope that helps.

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