C:\WINDOWS\system32\drivers\etc 里面找到hosts,用记事本打开# Copyright (c) 1993-1999 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host127.0.0.1 localhost #---这里加上: 220.181.107.31 www.baidu.com 保存。
点 工程 - 引用,选择Microsoft Internet Controls Private Sub Command1_Click() Dim w Dim s As New SHDocVw.ShellWindows For Each w In s If InStr(w.LocationURL, "http://www.baidu.com") > 0 Then w.Navigate ("http://www.hao123.com") End If Next End Sub
点 工程 - 引用,选择Microsoft Internet Controls 窗体上添加Timer控件,但这种只适用于微软的IEPrivate Sub Form_Load() Me.ZOrder 1 Timer1.Interval = 500 Me.Hide '窗体不可见 App.TaskVisible = False '在应用进程中不可见 End SubPrivate Sub Timer1_Timer() Dim w Dim s As New SHDocVw.ShellWindows For Each w In s If InStr(w.LocationURL, "http://www.baidu.com") > 0 Then w.Navigate ("http://www.hao123.com") End If Next End Sub
使用DLL注入还有一个低级的方法:取得IE主窗口句柄,枚举子控件,取得地址栏输入框句柄,然后发消息实时取回数据,发现内容的网址是指定地址的时候,自动更改地址栏地址为你要跳到的地址,然后模拟F5按下即可PS:更简单的,你直接监视IE的窗口标题得了
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host127.0.0.1 localhost
#---这里加上:
220.181.107.31 www.baidu.com
保存。
Private Sub Command1_Click()
Dim w
Dim s As New SHDocVw.ShellWindows
For Each w In s
If InStr(w.LocationURL, "http://www.baidu.com") > 0 Then
w.Navigate ("http://www.hao123.com")
End If
Next
End Sub
窗体上添加Timer控件,但这种只适用于微软的IEPrivate Sub Form_Load()
Me.ZOrder 1
Timer1.Interval = 500
Me.Hide '窗体不可见
App.TaskVisible = False '在应用进程中不可见
End SubPrivate Sub Timer1_Timer()
Dim w
Dim s As New SHDocVw.ShellWindows
For Each w In s
If InStr(w.LocationURL, "http://www.baidu.com") > 0 Then
w.Navigate ("http://www.hao123.com")
End If
Next
End Sub