主题:外挂软件屏蔽QQ2003(QQ2003II)广告__源码__浅谈几个API的应用
打开VB6 新建一个标准exe
在form1上放一个Timer~~用默认名字Timer1
把Form1的Visible属性设置为False,这样程序运行就在后台运行,所以关闭程序的时候~只要在任务管理器里面结束就可以了~~~其实也可以用设置热键的方法来结束程序~~不过我懒~~^_^~~
好了~~下面是Form1的源码~~:
为方便阅读,我把一些可以写成一句的代码拆开了,你可以自己合起来
__________________________________________________________________________________________________________________________________________________________
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Const WM_CLOSE = &H10
Private Const WM_GETTEXT = &HD
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_HIDE = 0
Private Const SW_SHOW = 5
Dim start As Long, a As Long
Dim rttitle As String, rttitleE As String, cnt As Long
Dim rttitle2 As String, cnt2 As Long
Dim rtn As Long
Dim FRect As RECT
Private Sub Command1_Click()
UpdateWindow start
End Sub
Private Sub Form_Load()
On Error Resume Next
If App.PrevInstance Then End '如果程序已经启动,则不重复加载
Shell App.Path & "/QQ.exe"
'如果你生成的EXE文件在QQ目录里面~~则会自动启动QQ
End Sub
Private Sub Timer1_Timer()
a = 0
Do
start = FindWindowEx(0, start, "#32770", vbNullString)
If start = 0 Then Exit Do
rttitle = Space(255)
cnt = Len(rttitle)
rtn = SendMessage(start, WM_GETTEXT, cnt, rttitle)
rttitle = Trim(rttitle)
rttitleE = Left(rttitle, 4)
rttitle = Right(rttitle, 5)
rttitle = Left(rttitle, 4)
If rttitle = "发送消息" Or rttitle = " 聊天中" Or rttitleE = "群 - " Then
Do
a = FindWindowEx(start, a, "Button", vbNullString)
If a = 0 Then Exit Do
GetWindowRect a, FRect
If FRect.Right - FRect.Left = 239 Then
'从循环开始,到这里为止,所有的代码都是用于找到屏幕上
'的QQ窗口中的广告
'程序运行到这里a的值就是广告窗口的句柄
'start的值就是用于交谈的窗口的句柄
MoveWindow a, -100, -100, 0, 0, 0
'这句是把广告移动到我们看不见的地方
ShowWindow start, SW_HIDE
ShowWindow start, SW_SHOW
'如果没有这2句,那么在原来广告的地方会有点花,碍眼
End If
Loop
End If
DoEvents
Loop
End Sub
__________________________________________________________________________________________________________________________________________________________
仔细看完这段代码~~觉得有些地方很奇怪~~明明有简单的方法不用~~怎么去用别扭的方法呢?
这个也是没办法~~~要怪就怪腾讯吧~~~他们在设计QQ时~~对许多我们常用的方法做了处理~~导致常规方法失效~~例如刷新窗口本可以用UpDataWindow~~可是我这里确用了
ShowWindow start, SW_HIDE
ShowWindow start, SW_SHOW
还有~~有人会问~~~为什么不直接把那个广告窗口杀掉算了~~~
经过我的试验~~杀了以后QQ会出现问题~~
嗯~~就是这样了~~~如果大家能帮忙完善一下就最好了~~~先谢过了~~
在form1上放一个Timer~~用默认名字Timer1
把Form1的Visible属性设置为False,这样程序运行就在后台运行,所以关闭程序的时候~只要在任务管理器里面结束就可以了~~~其实也可以用设置热键的方法来结束程序~~不过我懒~~^_^~~
好了~~下面是Form1的源码~~:
为方便阅读,我把一些可以写成一句的代码拆开了,你可以自己合起来
__________________________________________________________________________________________________________________________________________________________
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Const WM_CLOSE = &H10
Private Const WM_GETTEXT = &HD
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_HIDE = 0
Private Const SW_SHOW = 5
Dim start As Long, a As Long
Dim rttitle As String, rttitleE As String, cnt As Long
Dim rttitle2 As String, cnt2 As Long
Dim rtn As Long
Dim FRect As RECT
Private Sub Command1_Click()
UpdateWindow start
End Sub
Private Sub Form_Load()
On Error Resume Next
If App.PrevInstance Then End '如果程序已经启动,则不重复加载
Shell App.Path & "/QQ.exe"
'如果你生成的EXE文件在QQ目录里面~~则会自动启动QQ
End Sub
Private Sub Timer1_Timer()
a = 0
Do
start = FindWindowEx(0, start, "#32770", vbNullString)
If start = 0 Then Exit Do
rttitle = Space(255)
cnt = Len(rttitle)
rtn = SendMessage(start, WM_GETTEXT, cnt, rttitle)
rttitle = Trim(rttitle)
rttitleE = Left(rttitle, 4)
rttitle = Right(rttitle, 5)
rttitle = Left(rttitle, 4)
If rttitle = "发送消息" Or rttitle = " 聊天中" Or rttitleE = "群 - " Then
Do
a = FindWindowEx(start, a, "Button", vbNullString)
If a = 0 Then Exit Do
GetWindowRect a, FRect
If FRect.Right - FRect.Left = 239 Then
'从循环开始,到这里为止,所有的代码都是用于找到屏幕上
'的QQ窗口中的广告
'程序运行到这里a的值就是广告窗口的句柄
'start的值就是用于交谈的窗口的句柄
MoveWindow a, -100, -100, 0, 0, 0
'这句是把广告移动到我们看不见的地方
ShowWindow start, SW_HIDE
ShowWindow start, SW_SHOW
'如果没有这2句,那么在原来广告的地方会有点花,碍眼
End If
Loop
End If
DoEvents
Loop
End Sub
__________________________________________________________________________________________________________________________________________________________
仔细看完这段代码~~觉得有些地方很奇怪~~明明有简单的方法不用~~怎么去用别扭的方法呢?
这个也是没办法~~~要怪就怪腾讯吧~~~他们在设计QQ时~~对许多我们常用的方法做了处理~~导致常规方法失效~~例如刷新窗口本可以用UpDataWindow~~可是我这里确用了
ShowWindow start, SW_HIDE
ShowWindow start, SW_SHOW
还有~~有人会问~~~为什么不直接把那个广告窗口杀掉算了~~~
经过我的试验~~杀了以后QQ会出现问题~~
嗯~~就是这样了~~~如果大家能帮忙完善一下就最好了~~~先谢过了~~