| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1095 人关注过本帖
标题:[求助]关于HttpSendRequest函数
只看楼主 加入收藏
克隆狼
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-5-8
收藏
 问题点数:0 回复次数:2 
[求助]关于HttpSendRequest函数
Public 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
请问,这个函数里的几个参数分别是什么意思?
另外如何解决由网速问题造成挂起的问题
搜索更多相关主题的帖子: HttpSendRequest 挂起 
2008-06-21 16:43
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
收藏
得分:0 
不了解。做什么用的函数?

我遇到网络连接一般用:WebBrowser,Inet,Winsock,xmlhttp
2008-06-21 17:15
克隆狼
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-5-8
收藏
得分:0 
具体的我也搞不大清楚,应该是发送一个请求吧(包括"Get"、"Post"、"Head")
我是用来返回待访问的资源是否存在,详细代码如下,郁闷的是执行到HttpSendRequest经常挂起:
Option Explicit
Public HttpQuery As HTTP_QUERY

Type HTTP_QUERY
     STATUS_CODE As String
     STATUS_TEXT As String
     RAW_HEADERS_CRLF As String
End Type

Public Function OpenInternet(ByVal Url As String, Optional ByVal Path As String)
    Dim hInternetOpen, hInternetConnect, hHttpOpenRequest, bRet
    Dim sBuff As String * 1024
    Dim lBuffLen As Long
    Dim Temp_HttpQuery As HTTP_QUERY
    If Not RunStop Then Exit Function
    HttpQuery = Temp_HttpQuery
    Url = Replace(Url, "http://", "")
    If Url = "" Then Exit Function
    hInternetOpen = InternetOpen("Open URL Application", _
                        INTERNET_OPEN_TYPE_PRECONFIG, _
                        vbNullString, _
                        vbNullString, _
                        0)
    DoEvents
    If (hInternetOpen <> 0) Then
' Type of service to access
        hInternetConnect = InternetConnect(hInternetOpen, _
                            Url, _
                            INTERNET_DEFAULT_HTTP_PORT, _
                            vbNullString, _
                            "HTTP/1.0", _
                            INTERNET_SERVICE_HTTP, _
                            0, 0)
        DoEvents
        If hInternetConnect <> 0 Then
' Brings the data across the wire even if it locally cached
            hHttpOpenRequest = HttpOpenRequest(hInternetConnect, _
                                "HEAD", _
                                Path, _
                                vbNullString, _
                                vbNullString, _
                                0, _
                                INTERNET_FLAG_RELOAD, 0)
            DoEvents
            If hHttpOpenRequest <> 0 Then
                bRet = HttpSendRequest(hHttpOpenRequest, vbNullString, 0, vbNullString, 0)
                If bRet Then
                    'response headers
                    lBuffLen = Len(sBuff)
                    If HttpQueryInfo(hHttpOpenRequest, HTTP_QUERY_STATUS_CODE, sBuff, lBuffLen, 0) = 1 Then
                        Temp_HttpQuery.STATUS_CODE = Replace(sBuff, Chr(0), "")
                    End If
                    lBuffLen = Len(sBuff)
                    If HttpQueryInfo(hHttpOpenRequest, HTTP_QUERY_STATUS_TEXT, sBuff, lBuffLen, 0) = 1 Then
                        Temp_HttpQuery.STATUS_TEXT = Replace(sBuff, Chr(0), "")
                    End If
                    lBuffLen = Len(sBuff)
                    If HttpQueryInfo(hHttpOpenRequest, HTTP_QUERY_RAW_HEADERS_CRLF, sBuff, lBuffLen, 0) = 1 Then
                        Temp_HttpQuery.RAW_HEADERS_CRLF = Replace(sBuff, Chr(0), "")
                    End If
                    DoEvents
                End If
            End If
        End If
    End If
    ' Close all handles
    If hInternetOpen <> 0 Then
        bRet = InternetCloseHandle(hInternetOpen)
    End If
    If hInternetConnect <> 0 Then
        bRet = InternetCloseHandle(hInternetConnect)
    End If
    If hHttpOpenRequest <> 0 Then
        bRet = InternetCloseHandle(hHttpOpenRequest)
    End If
HttpQuery = Temp_HttpQuery
Debug.Print Replace(HttpQuery.STATUS_CODE, Chr(0), "")
Debug.Print Replace(HttpQuery.STATUS_TEXT, Chr(0), "")
'Debug.Print Replace(HttpQuery.RAW_HEADERS_CRLF, Chr(0), "")
End Function
2008-06-21 19:01
快速回复:[求助]关于HttpSendRequest函数
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025252 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved