[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Using Default Browser

Posted on 1998-11-04
3
Medium Priority
?
154 Views
Last Modified: 2010-04-30
Can someone provide the code that would determine the users default browser and open it to a particular page?
0
Comment
Question by:clarwc
3 Comments
 
LVL 4

Accepted Solution

by:
idcanada earned 400 total points
ID: 1443048

' Place a Command Button and a Text Box

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_SHOW = 5


Private Sub Command1_Click()
    text1.text = "http://www.total.net/~idc/"
    ShellExecute hwnd, "open", Text1.Text, vbNullString, vbNullString, SW_SHOW
End Sub

0
 
LVL 14

Expert Comment

by:waty
ID: 1443049
Bad luck, someone has responded just before me, by the way, here is my response :

Use the following function, to view an HTM file with its associated default browser :

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

Public Function ExecuteWithAssociate(ByVal hwnd As Long, sExecute As String, Optional Param As Variant, Optional windowstyle As Variant) As Boolean
   ' #VBIDEUtils#************************************************************
   ' * Programmer Name  : Waty Thierry
   ' * Web Site         : www.geocities.com/ResearchTriangle/6311/
   ' * E-Mail           : waty.thierry@usa.net
   ' * Date             : 9/10/98
   ' * Time             : 11:48
   ' * Module Name      : Execute_Module
   ' * Module Filename  :Execute.bas
   ' * Procedure Name   : ExecuteWithAssociate
   ' * Parameters       :
   ' *                    ByVal hWnd As Long
   ' *                    S As String
   ' *                    Optional Param As Variant
   ' *                    Optional windowstyle As Variant
   ' **********************************************************************
   ' * Comments         :
   ' * Executes a file with it's associated program.
   ' *   windowstyle uses the same constants as the Shell function:
   ' *      vbHide   0
   ' *      vbNormalFocus  1
   ' *      vbMinimizedFocus  2
   ' *      vbMaximizedFocus  3
   ' *      vbNormalNoFocus   4
   ' *      vbMinimizedNoFocus   6
   ' *
   ' *  returns true on success
   ' *
   ' *
   ' **********************************************************************
   
   Dim i As Long

   If IsMissing(windowstyle) Then windowstyle = vbNormalFocus

   i = ShellExecute(hwnd, vbNullString, sExecute, IIf(IsMissing(Param) Or (Param = ""), vbNullString, CStr(Param)), GetPath(sExecute), CLng(windowstyle))
   If i > 32 Then
      ExecuteWithAssociate = True
   Else
      ExecuteWithAssociate = False
   End If
   
End Function

Public Function GetPath(s As String) As String
   '
   '  Returns the path portion of a file + pathname
   '
   
   Dim i As Integer
   Dim J As Integer

   i = 0
   J = 0

   i = InStr(s, "\")
   Do While i <> 0
      J = i
      i = InStr(J + 1, s, "\")
   Loop

   If J = 0 Then
      GetPath = ""
   Else
      GetPath = Left$(s, J)
   End If

End Function

0
 

Author Comment

by:clarwc
ID: 1443050
Works Great thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month17 days, 14 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question