下载首页 | 资讯中心 | 下载分类 | 最近更新 | 排 行 榜 | 国产软件 | 国外软件 | 汉化补丁 |
文章搜索: 分类 关键字 收藏本站设为首页
您的位置:首页网页设计ASP程序 → VB 从零开始编外挂(八)__教程
VB 从零开始编外挂(八)__教程
日期:2007-5-20 1:20:22 人气:306     [ ]
上一页 [1] [2] [3] [4] [5] [6] [7] [8] 下一页
End Type

'常量
Public Const PF_INET = 2
Public Const SOCK_RAW = 3
Public Const AF_INET = 2
Public Const FD_READ = &H1
Public Const SIO_RCVALL = &H98000001
Public Const EM_REPLACESEL = &HC2

Public host As HOSTENT
Public s As Long
Public sock As sockaddr

Public Header As ipheader
Public tcpHead As tcp_hdr
Public udpHead As udp_hdr
Public icmpHead As icmp_hdr


Public resarray() As Long, str As String
Public i As Long, CountID As Long 'i 为临时变量,循环语句用,CountID 用来计算一共有多少个数据包
Public protocol As String
Public buffer() As Byte '存放数据包
Public res As Long '返回值,临时变量
Public ExitID As Boolean '退出标识


'开始
Public Sub Wstartup()
Dim Data As WSAdata
Call WSAstartup(&H202, Data) '初始化 Winsock 为 2.2
End Sub

'结束
Public Sub WCleanup(s As Long)
Call WsACleanup '关闭 Winsock
closesocket s
End Sub

'获得当前主机的 IP
Public Function ip(ByRef address As String) As String
Dim pip As Long
Dim uip As Long
Dim s As Long
Dim ss As String
Dim cul As Long

CopyMemory host, ByVal gethostbyname(address), Len(host) '将 gethostbyname 获得的值放到 host
CopyMemory pip, ByVal host.h_addr_list, 4 '将 host.h_addr_list 的值放到 pip
CopyMemory uip, ByVal pip, 4 '将 pip 的值放到 uip
s = inet_ntoa(uip) '将 uip 转换为标准的 IPV4 格式
ss = Space(lstrlen(s)) '去掉空格
cul = lstrcpy(ss, s)
ip = ss '获得 IPV4 格式的地址并将其放如 ip
End Function

'获得当前机器的主机名
Public Function hostname() As String
Dim r As Long
Dim s As String
Dim host As String

Wstartup
host = String(255, 0)
r = gethostname(host, 255) '获得当前主机的主机名

If r = 0 Then
hostname = Left(host, InStr(1, host, vbNullChar) - 1)
End If

End Function

'连接 IP
Public Sub Connecting(ByRef ip As String, pic As PictureBox)
Dim res As Long, buf As Long, bufb As Long
buf = 1

Wstartup '初始化 Winsock

s = socket(AF_INET, SOCK_RAW, 0) '创建套接字,s 是socket功能返回的文件描述符
If s < 1 Then
Call WCleanup(s)
Exit Sub '如果创建失败则退出
End If

sock.sin_family = AF_INET 'socket类型
sock.sin_addr = inet_addr(ip) '所用的IP地址
res = bind(s, sock, Len(sock)) '绑定端口

If res <> 0 Then
Call WCleanup(s)
Exit Sub '如果绑定失败则退出
End If

res = WSAIoctl(s, SIO_RCVALL, buf, Len(buf), 0, 0, bufb, ByVal 0, ByVal 0) '改变Socket IO模式,将其改为混乱模式,即接受与自己无关的数据,则 SIO_RCVALL

If res <> 0 Then
Call WCleanup(s)
Exit Sub
End If

res = WSAAsyncSelect(s, pic.hWnd, &H202, ByVal FD_READ) '设置套接字处于阻塞方式或者非阻塞方式,消息发送的窗口是 pic,即 Form1.Picture1

If res <> 0 Then
Call WCleanup(s)
Exit Sub
End If

End Sub

'接收信息
Public Sub Recibir(s As Long, ByVal RecFormat As Long)
If RecFormat = FD_READ Then
ReDim buffer(2000) '重定义缓冲区大小为 2000
Do
res = recv(s, buffer(0), 2000, 0&) '接收信息
If res > 0 Then

ReDim Preserve resarray(CountID) '改变数组大小,并保留以前的数据
出处:本站原创 作者:佚名
 阅读排行
01.精美qq空间横幅代码
02.最酷qq个性女生网名
03.最新又有免费QQ秀啦《..
04.巧用透明FlaSh扮靓你的..
05.花之神匠代码(最新代码..
06.最新QQ空间免费导航
07.最新免费个人形象设置..
08.最新qq空间flash代码m..
09.CSS技术结合图像实现动..
10.Photoshop光影魔术师:..
11.QQ音速种子狂刷
12.最新QQ空间透明代码
13.PS实例教程:教你制作结..
14.Photoshop光影魔术师:..
15.制作背景图__教程
16.用Photoshop制作漂亮的..
17.如何获得QQ音速种子
18.≤QQ空间代码≥在日志..
19.网页浮动广告的制作代..
20.用Photoshop制作大红灯..
21.常用CSS
22.Photoshop给靓丽美女打..
 推荐文章
·Photoshop 表现技法之..
·快速将你的相片矢量化..
·PHOTOSHOP制作炽热的太..
·用Photoshop制作美丽的..
·流行杀手的娃娃工厂__..
·打造8号台球__教程
·PHOTOSHOP制作待机MM图..
·用Photoshop帮MM做纹身..
·PHOTOSHOP美眉着色绝招..
·PHOTOSHOP花露的制作_..
·PHOTOSHOP渐变工具的巧..
·PHOTOSHOP手绘奥兰多-..
·高难度抠图两种方法__..
·Photoshop高尔夫球的制..
·Photoshop打造精美玉佩..
Eqxia_COM下载站 版权所有 Copyright© 2001-2005 Www.eqxia.COM, All Rights Reserved.