Private Sub Command1_Click()
Dim comfile
Dim comid
strA = URLEncoding("comfile=xp.dll,中文可以不.&comid=hyxd111")
Set http = CreateObject("MSXML2.XMLHTTP")
With http
.Open "POST ", "http://127.0.0.1/post.asp", False
.setRequestHeader "Content-Type ", "application/x-www-form-urlencoded "
.setRequestHeader "Content-Length ", Len(strA)
.send strA
Text1.Text = bytes2BSTR(.responseBody)
End With
Label1.Caption = "完成 "
End Sub
Function URLEncoding(vstrIn)
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vstrIn, i, 1)
If Abs(Asc(ThisChr)) < &HFF Then
strReturn = strReturn & ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode < 0 Then
innerCode = innerCode + &H10000
End If
Hight8 = (innerCode And &HFF00) \ &HFF
Low8 = innerCode And &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
URLEncoding = strReturn
End Function
Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn, i, 1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn, i + 1, 1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function