有关Winsock.ocx控件的问题
在网上有使用Winsock.ocx控件的vbs脚本,但是转化为au3的时候遇到困难主要是 Winsock1_DataArrival(ByVal bytesTotal As Long)
这个事件上的问题!
请求帮助
[ 本帖最后由 gto250 于 2008-6-7 21:10 编辑 ] 看代码应该是VB的,能发全部代码吗? vb=====================================vb
Private Sub Command3_Click()
Text6.Text = ""
With Winsock1
.RemoteHost = "wwww.shuwu.com"
.RemotePort = 80
End With
If Winsock1.State = 0 Then Winsock1.Connect
Do While Winsock1.State <> 7
DoEvents
Loop
Call Winsock1_Connect
End Sub
Private Sub Winsock1_Connect()
strCommand = "POST /cgi-bin/common/cgi_view_album HTTP/1.1" + vbCrLf
strCommand = strCommand + "Host:www.shuwu.com" & vbCrLf
strCommand = strCommand + "Content-Type: application/x-www-form-urlencoded" + vbCrLf
strCommand = strCommand + "Content-Length:" & lendata & vbCrLf
strCommand = strCommand + "Cookie:session=" & zhi & vbCrLf & vbCrLf
strCommand = strCommand + postdata
Winsock1.SendData strCommand
End Sub
Private Sub Winsock1_Close()
Winsock1.Close
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strdata As String
Winsock1.GetData strdata
Text6.Text = Text6.Text + strdata
End Sub
vbs=======================================vbs
dim revdata
dim sendata
//创建Winsock对像
set sock=createobject("MSWinsock.Winsock")
//使用UDP协议
//建立连接
sock.Protocol=1sock.Connect "127.0.0.1",1234
//定义要发送的数据
sendata="Hello!!!"&chr(13)
//发送我们要发的数据
sock.senddata sendata
do
//如果有数据回应就显示它
if sock.BytesReceived>0 then
//定义接收数据类型(数据类型有vbByte、vbInteger、vbLong、vbSingle
//vbDouble、vbCurrency、vbDate、vbBoolean、vbError、vbString、vbArray+vbByte)
//也只有定义好要接收的数据类型才能收到数据,不然会收到的是一堆乱码;
sock.getdata revdata,vbString;
sendata=inputbox (revdata,"RecviedData","请输入你要发的信息")
sock.senddata senddata & chr(13)
//当收到含有"exit"字串时结束VBS进程
if instr(revdata,"exit") then exit do
else
end if
loop
//关闭对像套接
sock.close
sock.getdata revdata,vbString;
主要是这个数据类型不能设置 不需要Winsock了
页:
[1]