Private Sub 登陆_Click()
Dim cParamName As String
Dim cParamFlavor As String
Dim cSeparator As String
Dim cPostData As String
ReDim aByte(0) As Byte
Dim edtPostData As String
Dim i As Integer
cParamName = "userName="
cParamFlavor = "userPass="
cSeparator = "&"
cPostData = cParamName & userName.Text _
& cSeparator & cParamFlavor & userPass.Text & cSeparator & "refer=/MsgSendChoose.jsp?zmccCatalog=0801"
PackBytes aByte(), cPostData
For i = LBound(aByte) To UBound(aByte)
edtPostData = edtPostData + Chr(aByte(i))
Next
Dim vPost As Variant
vPost = aByte
Dim vFlags As Variant
Dim vTarget As Variant
Dim vHeaders As Variant
vHeaders = _
"Content-Type: application/x-www-form-urlencoded" _
+ Chr(10) + Chr(13)
Form1.WebBrowser1.Navigate "http://211.140.32.131//loginAction.do", _
vFlags, vTarget, vPost, vHeaders
ys = 0
su = 0
pas = ""
End Sub
Public Function URLEncode(ByRef strURL As String) As String
Dim i As Long
Dim tempStr As String
For i = 1 To Len(strURL)
If Asc(Mid(strURL, i, 1)) < 0 Then
tempStr = "%" & Right(CStr(Hex(Asc(Mid(strURL, i, 1)))), 2)
tempStr = "%" & Left(CStr(Hex(Asc(Mid(strURL, i, 1)))), Len(CStr(Hex(Asc(Mid(strURL, i, 1))))) - 2) & tempStr
URLEncode = URLEncode & tempStr
ElseIf (Asc(Mid(strURL, i, 1)) >= 65 And Asc(Mid(strURL, i, 1)) <= 90) Or (Asc(Mid(strURL, i, 1)) >= 97 And Asc(Mid(strURL, i, 1)) <= 122) Then
URLEncode = URLEncode & Mid(strURL, i, 1)
Else
URLEncode = URLEncode & "%" & Hex(Asc(Mid(strURL, i, 1)))
End If
DoEvents
Next
End Function
Public Function URLDecode(ByRef strURL As String) As String
Dim i As Long
If InStr(strURL, "%") = 0 Then URLDecode = strURL: Exit Function
For i = 1 To Len(strURL)
If Mid(strURL, i, 1) = "%" Then
If Val("&H" & Mid(strURL, i + 1, 2)) > 127 Then
URLDecode = URLDecode & Chr(Val("&H" & Mid(strURL, i + 1, 2) & Mid(strURL, i + 4, 2)))
i = i + 5
Else
URLDecode = URLDecode & Chr(Val("&H" & Mid(strURL, i + 1, 2)))
i = i + 2
End If
Else
URLDecode = URLDecode & Mid(strURL, i, 1)
End If
DoEvents
Next
End Function
Public Sub PackBytes(ByteArray() As Byte, ByVal PostData As String)
Dim iNewBytes As Long
iNewBytes = Len(PostData) - 1
If iNewBytes < 0 Then
Exit Sub
End If
ReDim ByteArray(iNewBytes)
For i = 0 To iNewBytes
ch = Mid(PostData, i + 1, 1)
DoEvents
If ch = Space(1) Then
ch = "+"
End If
ByteArray(i) = Asc(ch)
Next
End Sub