VB WinInet Post 发送表单数据模块,VB WinInet Post 发送表单数据,VB WinInet Post 表单数据模块,VB WinInet Post 表单数据,VB WinInet 发送表单数据,VB WinInet Post 数据,VB WinInet 发送数据,VB WinInet 发送表单,VB WinInet Post 表单,VB WinInet 发送表单数据模块,VB WinInet 发送表单数据,VB Post 发送表单数据,VB Post 表单数据,VB Post 发送数据,VB Post 发送,VB Post 数据,VB Post 表单,VB Post,VB 表单,InternetOpen,InternetConnect,InternetReadFile,HttpOpenRequest,HttpSendRequest,InternetCloseHandle,HttpAddRequestHeaders,wininet.dll,InternetOpen("http generic", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0),INTERNET_OPEN_TYPE_PRECONFIG = 0,INTERNET_SERVICE_HTTP = 3,INTERNET_DEFAULT_HTTP_WebPort = 80,InternetConnect(IntOpen, WebServer, WebPort, vbNullString, "HTTP/1.0", INTERNET_SERVICE_HTTP, 0, 0),INTERNET_FLAG_RELOAD = &H80000000,HttpOpenRequest(IntConnect, "POST", ScriptName, "HTTP/1.0", vbNullString, 0, INTERNET_FLAG_RELOAD, 0),HTTP_ADDREQ_FLAG_ADD = &H20000000,HTTP_ADDREQ_FLAG_REPLACE = &H80000000。

VB WinInet Post 发送表单数据模块:

Option Explicit

'Wininet Post数据模块
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal lpszCallerName As String, ByVal dwAccessType As Long, ByVal lpszProxyName As String, ByVal lpszProxyBypass As String, ByVal dwFlags As Long) As Long
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal lpszServerName As String, ByVal nProxyWebPort As Integer, ByVal lpszUsername As String, ByVal lpszPassword As String, ByVal dwService As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, ByVal IBuffer As String, ByVal lNumBytesToRead As Long, ByteNumberRead As Long) As Integer
Private Declare Function HttpOpenRequest Lib "wininet.dll" Alias "HttpOpenRequestA" (ByVal hInternetSession As Long, ByVal lpszVerb As String, ByVal lpszObjectName As String, ByVal lpszVersion As String, ByVal lpszReferer As String, ByVal lpszAcceptTypes As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Declare Function HttpSendRequest Lib "wininet.dll" Alias "HttpSendRequestA" (ByVal hHttpRequest As Long, ByVal sHeaders As String, ByVal lHeadersLength As Long, ByVal sOptional As String, ByVal lOptionalLength As Long) As Boolean
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInternetHandle As Long) As Boolean
Private Declare Function HttpAddRequestHeaders Lib "wininet.dll" Alias "HttpAddRequestHeadersA" (ByVal hHttpRequest As Long, ByVal sHeaders As String, ByVal lHeadersLength As Long, ByVal lModifiers As Long) As Integer

Public Function PostInfo(WebServer As String, WebPort, ScriptName As String, PostData As String) 'PostInfo("127.0.0.1", 80, "/a.asp", "Cmd=Fuck")
    On Error GoTo Over
    Dim IntOpen As Long, IntConnect As Long, XHttpOpenRequest As Long, BRet As Boolean
    IntOpen = 0
    IntConnect = 0
    XHttpOpenRequest = 0
    '使用注册表访问设置。
    Const INTERNET_OPEN_TYPE_PRECONFIG = 0
    IntOpen = InternetOpen("http generic", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
    If IntOpen <> 0 Then
        '类型的服务访问。
        Const INTERNET_SERVICE_HTTP = 3
        Const INTERNET_DEFAULT_HTTP_WebPort = 80
        '更改服务器到服务器的名称
        IntConnect = InternetConnect(IntOpen, WebServer, WebPort, vbNullString, "HTTP/1.0", INTERNET_SERVICE_HTTP, 0, 0)
        If IntConnect <> 0 Then
            '带来的数据通过线路即使本地缓存。
            Const INTERNET_FLAG_RELOAD = &H80000000
            XHttpOpenRequest = HttpOpenRequest(IntConnect, "POST", ScriptName, "HTTP/1.0", vbNullString, 0, INTERNET_FLAG_RELOAD, 0)
            If XHttpOpenRequest <> 0 Then
                Dim HttpHeader As String
                Const HTTP_ADDREQ_FLAG_ADD = &H20000000
                Const HTTP_ADDREQ_FLAG_REPLACE = &H80000000
                HttpHeader = "Content-Type: application/x-www-form-urlencoded" & vbCrLf
                BRet = HttpAddRequestHeaders(XHttpOpenRequest, HttpHeader, Len(HttpHeader), HTTP_ADDREQ_FLAG_REPLACE Or HTTP_ADDREQ_FLAG_ADD)
                BRet = HttpSendRequest(XHttpOpenRequest, vbNullString, 0, PostData, Len(PostData))
                Dim TheLoop As Boolean, RBuffer As String * 2048, ByteNumberRead As Long, IBuffer As String
                TheLoop = True
                While TheLoop
                    RBuffer = vbNullString
                    TheLoop = InternetReadFile(XHttpOpenRequest, RBuffer, Len(RBuffer), ByteNumberRead)
                    IBuffer = IBuffer & Left(RBuffer, ByteNumberRead)
                    If Not CBool(ByteNumberRead) Then TheLoop = False
                Wend
                PostInfo = IBuffer
                BRet = InternetCloseHandle(XHttpOpenRequest)
            End If
            BRet = InternetCloseHandle(IntConnect)
        End If
        BRet = InternetCloseHandle(IntOpen)
    End If
    Exit Function
Over:
    PostInfo = ""
End Function

MsgBox PostInfo("127.0.0.1", 80, "/a.asp", "Cmd=Fuck")