
How to launch webbrowser from VB6?
Try this:
rc = ComWeb_LaunchWWW(Me.hwnd, "microsoft.com") 'might need
www.microsoft.com
Option Explicit
'Example call: rc = ComWeb_LaunchWWW(Me.hwnd,
"bcassessment.icw.gov.bc.ca")
'Common bas module code follows:
Const SW_SHOWNORMAL = 1
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 Declare Function FindExecutable Lib "shell32.dll" Alias
"FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String,
ByVal lpResult As String) As Long
Public Function ComWeb_LaunchWWW(lYourHwnd As Long, sWWWURL As String)
As Boolean
'This function launches the users default web browser to the specified
web site
'True is returned upon success, False is returned otherwise
Dim sFileName As String, sDummy As String
Dim sBrowserExec As String * 255
Dim lRetVal As Long
Dim iFileNumber As Integer
On Error Resume Next
sBrowserExec = Space$(255)
sFileName = "C:\temphtm.htm"
iFileNumber = FreeFile()
'create a dummy html file so we can determine the default browser
location
Open sFileName For Output As #iFileNumber
Write #iFileNumber, "<HTML> <\HTML>"
Close #iFileNumber
'this function will return the browser path
lRetVal = FindExecutable(sFileName, sDummy, sBrowserExec)
If lRetVal <= 32 Then
ComWeb_LaunchWWW = False
Exit Function
End If
'now tell the browser to open the web site
lRetVal = ShellExecute(lYourHwnd, "open", sBrowserExec, sWWWURL,
sDummy, SW_SHOWNORMAL)
If lRetVal <= 32 Then
ComWeb_LaunchWWW = False
Exit Function
End If
'get rid of the temp html file
Kill sFileName
ComWeb_LaunchWWW = True
Err.Clear
End Function
This code came originally from VB Tips I think???
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.