# Re: vb呼叫IE

Posted by Roger on December 01, 1998 at 17:58:46:

In Reply to: vb呼叫IE posted by yeong huann on November 17, 1998 at 20:51:05:

: 1.请问如何利用VB写出一个程式,呼叫IE或NETSAPE,并开启特定的网址?
: 2.如果系统上有两个以上的浏览器如何判定那一个浏览器为内定浏览器?

很简单,
就直接立一个xxxx.html,然后利用档案总管去开,
Windows就会去呼叫内定的browser了.

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

Sub OpenURL(ByVal sURL As String)
Dim FileName, dummy As String
Dim BrowserExec As String * 255
Dim RetVal As Long
Dim FileNumber As Integer
' First, create a known, temporary HTML file
BrowserExec = Space(255)
FileName = "C:\temphtm.HTM"
FileNumber = FreeFile ' Get unused file number
Open FileName For Output As #FileNumber ' Create temp HTML file
Write #FileNumber, "
<\HTML>" ' Output text
Close #FileNumber ' Close file
' Then find the application associated with it
RetVal = FindExecutable(FileName, dummy, BrowserExec)
BrowserExec = Trim(BrowserExec)
' If an application is found, launch it!
If RetVal <= 32 Or IsEmpty(BrowserExec) Then ' Error
MsgBox "无法启动网路浏览", vbExclamation, _
"无网路浏览"
Else
If sURL = "http://" Then
sURL = "http://www.hinet.net"
End If
RetVal = ShellExecute(MDIForm1.hwnd, "open", BrowserExec, _
sURL, dummy, SW_SHOWNORMAL)
If RetVal <= 32 Then ' Error
MsgBox "网页无法开启", vbExclamation, "URL 连接失败"
End If
End If
Kill FileName ' delete temp HTML file

Follow Ups: