vb写外挂第十天-该来个总结了吼吼··

时间:2011-04-30 02:20 来源:未知 作者:admin 点击:

这里面有些东西是论坛那个VB一天一天写外挂教程里没有的东西,虽然不是必须的
不过还是有些实际意义
1、VB的小图标处理
2、后台鼠标的模拟移动和点击
3、从进程获得文件执行路径
4、打开文件夹的操作
5、比sleep好用的延时函数
所有代码都是参考人家的做的,我理解新人没有实例的痛苦,我也是参考一天一天的教程写出来的
在此再次感谢
新增的功能算是一个补充吧

Public Function Delayt(ByVal num As Long)  '延时函数,不会假死,这个函数是论坛上的
Dim sTime As Long
sTime = 1
While sTime <= num
sTime = sTime + 1
DoEvents
Sleep 1
Wend
End Function

Private Sub Command1_Click()
Text9.Text = GetFolder(Me.hWnd, "请选择一个文件夹:")
End Sub
'-----------小图标处理函数-------------------
Private Sub Form_Resize()
If Me.WindowState = 1 Then
cSysTray1.InTray = True
Me.Visible = False
End If
End Sub
Private Sub cSysTray1_MouseUp(Button As Integer, Id As Long)
Me.WindowState = 0      '程序回复到Normal状态
Me.Visible = True      '从任务栏中清除图标
cSysTray1.InTray = False      '令程序界面可见

End Sub
'----------------根据进程获取程序路径
Function GetProcessPathByProcessID(PID As Long) As String
On Error GoTo Z
Dim cbNeeded As Long
Dim szBuf(1 To 250) As Long
Dim Ret As Long
Dim szPathName As String
Dim nSize As Long
Dim hProcess As Long
hProcess = OpenProcess( &H400 Or &H10, 0, PID)
If hProcess <> 0 Then
Ret = EnumProcessModules(hProcess, szBuf(1), 250, cbNeeded)
If Ret <> 0 Then
szPathName = Space(260)
nSize = 500
Ret = GetModuleFileNameExA(hProcess, szBuf(1), szPathName, nSize)
GetProcessPathByProcessID = Left(szPathName, Ret)
End If
End If
Ret = CloseHandle(hProcess)
If GetProcessPathByProcessID = "" Then
GetProcessPathByProcessID = "SYSTEM"
End If
Exit Function
Z:
End Function



'-----------------------这是一个打开游戏工作目录的函数---------------
Private Function GetFolder(ByVal hWnd As Long, Optional Title As String) As String
Dim bi As BROWSEINFO
Dim pidl As Long
Dim folder As String
folder = Space(255)
With bi
If IsNumeric(hWnd) Then .hOwner = hWnd
.pidlroot = 0
If Title <> "" Then
.lpszTitle = Title & Chr$(0)
Else
.lpszTitle = "选择目录" & Chr$(0)
End If
End With

pidl = SHBrowseForFolder(bi)
If SHGetPathFromIDlist(ByVal pidl, ByVal folder) Then
GetFolder = Left(folder, InStr(folder, Chr$(0)) - 1)
Else
GetFolder = ""
End If
End Function

'-----------------按键转换函数-----------------------------------
Private Function Key(Anjian As Long) As Long
Select Case Anjian
Case 0
Key = &H70
Case 1
Key = &H71 'F2
Case 2
Key = &H72 'F3
Case 3
Key = &H73 'F4
Case 4
Key = &H74
Case 5
Key = &H75
Case 6
Key = &H76
Case 7
Key = &H77
Case 8
Key = &H31 '1
Case 9
Key = &H32 '2
Case 10
Key = &H33 '3
Case 11
Key = &H34
Case 12
Key = &H35 '5
Case 13
Key = &H36
Case 14
Key = &H37
Case 15
Key = &H38
Case 16
Key = &H39 '9
Case 17
Key = &H30 '0
End Select
End Function
Private Sub Command4_Click()
'此处是作为运行游戏的语句的,但是目前还没有能够解决这个问题

End Sub

Private Sub Form_Load()
hwd = FindWindow("new3d_WCLASS", "Childhood 3d Client")
If hwd = 0 Then
Label17.Caption = "  游戏末运行,请先打开游戏"
End If
GetWindowThreadProcessId hwd, PID  '获取进程标识符
'将进程标识符做为参数,返回目标进程PID的句柄,得到此句柄后
'即可对目标进行读写操,PROCESS_ALL_ACCESS表示完全控制,权限最大
If PID <> 0 Then
Text9.Text = GetProcessPathByProcessID(PID)
End If
b = 0
c = 0

test1 = 0
test2 = 0
End Sub


Private Sub Form_Unload(Cancel As Integer)
Timer1.Enabled = False
End Sub

Private Function MyHotKey(vKeyCode) As Boolean
MyHotKey = (GetAsyncKeyState(vKeyCode) < 0)
End Function
'-------------隐藏游戏-----------------------------

分享按钮
评论区
正在载入评论数据中...