Launch Default Web Browser


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Launch Default Web Browser

  1. #1
    Abdulla Hussein Al-Adhal Guest

    Launch Default Web Browser

    Hi,
    Can someone tell me how to lauch a system default browser without
    supplying an html web link. i.e. it goes into default home page.

    Thanks
    Abdulla



  2. #2
    Ian King Guest

    Re: Launch Default Web Browser

    Hi Abdulla

    You can do it this way,

    Dim strBrowserPath As String
    strBrowserPath = GetExePath("htm")
    If strBrowserPath <> "NoDefApp" Then Shell(strBrowserPath, vbNormal)

    *********************
    Option Explicit

    Private Declare Function FindExecutable Lib "shell32.dll" Alias _
    "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, _
    ByVal lpResult As String) As Long

    Public Function GetExePath(Extension As String) As String
    Dim Result As String, z As Long, Path As String
    Dim FileName As String, fnum As Integer
    If Extension = "" Then
    GetExePath = "NoExtension"
    Exit Function
    End If
    If Left$(Extension, 1) = "." Then _
    Extension = Right$(Extension, Len(Extension) - 1)
    Result = Space$(270)
    Path = Environ("temp") & "\"
    FileName = "~testing." & Extension
    fnum = FreeFile
    Open Path & FileName For Output As #fnum
    Close #fnum
    z = FindExecutable(FileName, Path, Result)
    Kill Path & FileName
    Do While fnum > 0
    fnum = InStr(Result, Chr(0))
    If fnum > 0 Then Mid(Result, fnum, 1) = " "
    Loop
    Result = Trim(Result)
    fnum = InStr(1, Result, ".EXE", vbTextCompare)
    If Len(Result) > 0 And fnum > 0 Then
    Result = Left$(Result, fnum) & "EXE"
    GetExePath = Result
    Else
    GetExePath = "NoDefApp"
    End If
    End Function
    ***********************************

    regards

    Ian

    ** invalid email address, change dk to denmark

    homepage http://www.kingsoft-denmark.com/


    Abdulla Hussein Al-Adhal <aladhal@metastorm.com> wrote in message
    news:3961c896$1@news.devx.com...
    > Hi,
    > Can someone tell me how to lauch a system default browser without
    > supplying an html web link. i.e. it goes into default home page.
    >
    > Thanks
    > Abdulla
    >
    >




  3. #3
    Ian King Guest

    Re: Launch Default Web Browser

    Hi Abdulla

    You can do it this way,

    Dim strBrowserPath As String
    strBrowserPath = GetExePath("htm")
    If strBrowserPath <> "NoDefApp" Then Shell(strBrowserPath, vbNormal)

    *********************
    Option Explicit

    Private Declare Function FindExecutable Lib "shell32.dll" Alias _
    "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, _
    ByVal lpResult As String) As Long

    Public Function GetExePath(Extension As String) As String
    Dim Result As String, z As Long, Path As String
    Dim FileName As String, fnum As Integer
    If Extension = "" Then
    GetExePath = "NoExtension"
    Exit Function
    End If
    If Left$(Extension, 1) = "." Then _
    Extension = Right$(Extension, Len(Extension) - 1)
    Result = Space$(270)
    Path = Environ("temp") & "\"
    FileName = "~testing." & Extension
    fnum = FreeFile
    Open Path & FileName For Output As #fnum
    Close #fnum
    z = FindExecutable(FileName, Path, Result)
    Kill Path & FileName
    Do While fnum > 0
    fnum = InStr(Result, Chr(0))
    If fnum > 0 Then Mid(Result, fnum, 1) = " "
    Loop
    Result = Trim(Result)
    fnum = InStr(1, Result, ".EXE", vbTextCompare)
    If Len(Result) > 0 And fnum > 0 Then
    Result = Left$(Result, fnum) & "EXE"
    GetExePath = Result
    Else
    GetExePath = "NoDefApp"
    End If
    End Function
    ***********************************

    regards

    Ian

    ** invalid email address, change dk to denmark

    homepage http://www.kingsoft-denmark.com/


    Abdulla Hussein Al-Adhal <aladhal@metastorm.com> wrote in message
    news:3961c896$1@news.devx.com...
    > Hi,
    > Can someone tell me how to lauch a system default browser without
    > supplying an html web link. i.e. it goes into default home page.
    >
    > Thanks
    > Abdulla
    >
    >




  4. #4
    Abdulla Hussein Al-Adhal Guest

    Re: Launch Default Web Browser

    I will try that

    Cheers Ian

    "Ian King" <advice@kingsoft-dk.com> wrote in message
    news:3962e6ff$1@news.devx.com...
    > Hi Abdulla
    >
    > You can do it this way,
    >
    > Dim strBrowserPath As String
    > strBrowserPath = GetExePath("htm")
    > If strBrowserPath <> "NoDefApp" Then Shell(strBrowserPath, vbNormal)
    >
    > *********************
    > Option Explicit
    >
    > Private Declare Function FindExecutable Lib "shell32.dll" Alias _
    > "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, _
    > ByVal lpResult As String) As Long
    >
    > Public Function GetExePath(Extension As String) As String
    > Dim Result As String, z As Long, Path As String
    > Dim FileName As String, fnum As Integer
    > If Extension = "" Then
    > GetExePath = "NoExtension"
    > Exit Function
    > End If
    > If Left$(Extension, 1) = "." Then _
    > Extension = Right$(Extension, Len(Extension) - 1)
    > Result = Space$(270)
    > Path = Environ("temp") & "\"
    > FileName = "~testing." & Extension
    > fnum = FreeFile
    > Open Path & FileName For Output As #fnum
    > Close #fnum
    > z = FindExecutable(FileName, Path, Result)
    > Kill Path & FileName
    > Do While fnum > 0
    > fnum = InStr(Result, Chr(0))
    > If fnum > 0 Then Mid(Result, fnum, 1) = " "
    > Loop
    > Result = Trim(Result)
    > fnum = InStr(1, Result, ".EXE", vbTextCompare)
    > If Len(Result) > 0 And fnum > 0 Then
    > Result = Left$(Result, fnum) & "EXE"
    > GetExePath = Result
    > Else
    > GetExePath = "NoDefApp"
    > End If
    > End Function
    > ***********************************
    >
    > regards
    >
    > Ian
    >
    > ** invalid email address, change dk to denmark
    >
    > homepage http://www.kingsoft-denmark.com/
    >
    >
    > Abdulla Hussein Al-Adhal <aladhal@metastorm.com> wrote in message
    > news:3961c896$1@news.devx.com...
    > > Hi,
    > > Can someone tell me how to lauch a system default browser without
    > > supplying an html web link. i.e. it goes into default home page.
    > >
    > > Thanks
    > > Abdulla
    > >
    > >

    >
    >




  5. #5
    Abdulla Hussein Al-Adhal Guest

    Re: Launch Default Web Browser

    I will try that

    Cheers Ian

    "Ian King" <advice@kingsoft-dk.com> wrote in message
    news:3962e6ff$1@news.devx.com...
    > Hi Abdulla
    >
    > You can do it this way,
    >
    > Dim strBrowserPath As String
    > strBrowserPath = GetExePath("htm")
    > If strBrowserPath <> "NoDefApp" Then Shell(strBrowserPath, vbNormal)
    >
    > *********************
    > Option Explicit
    >
    > Private Declare Function FindExecutable Lib "shell32.dll" Alias _
    > "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, _
    > ByVal lpResult As String) As Long
    >
    > Public Function GetExePath(Extension As String) As String
    > Dim Result As String, z As Long, Path As String
    > Dim FileName As String, fnum As Integer
    > If Extension = "" Then
    > GetExePath = "NoExtension"
    > Exit Function
    > End If
    > If Left$(Extension, 1) = "." Then _
    > Extension = Right$(Extension, Len(Extension) - 1)
    > Result = Space$(270)
    > Path = Environ("temp") & "\"
    > FileName = "~testing." & Extension
    > fnum = FreeFile
    > Open Path & FileName For Output As #fnum
    > Close #fnum
    > z = FindExecutable(FileName, Path, Result)
    > Kill Path & FileName
    > Do While fnum > 0
    > fnum = InStr(Result, Chr(0))
    > If fnum > 0 Then Mid(Result, fnum, 1) = " "
    > Loop
    > Result = Trim(Result)
    > fnum = InStr(1, Result, ".EXE", vbTextCompare)
    > If Len(Result) > 0 And fnum > 0 Then
    > Result = Left$(Result, fnum) & "EXE"
    > GetExePath = Result
    > Else
    > GetExePath = "NoDefApp"
    > End If
    > End Function
    > ***********************************
    >
    > regards
    >
    > Ian
    >
    > ** invalid email address, change dk to denmark
    >
    > homepage http://www.kingsoft-denmark.com/
    >
    >
    > Abdulla Hussein Al-Adhal <aladhal@metastorm.com> wrote in message
    > news:3961c896$1@news.devx.com...
    > > Hi,
    > > Can someone tell me how to lauch a system default browser without
    > > supplying an html web link. i.e. it goes into default home page.
    > >
    > > Thanks
    > > Abdulla
    > >
    > >

    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center