WinHTTP错误信息处理

WinHTTP错误信息处理

Not all WinHTTP API functions report errors in the same way.

WinHTTP API各种函数返回错误的方式不尽相同。

Some functions, such as WinHttpSetTimeouts, return a BOOL that indicates failure whenFALSE. If FALSE is returned, callers interested in the error should callGetLastError. If GetLastError is called when the function succeded (returned anything butFALSE), the returned value is unpredictable and may change between Windows versions, Service Packs, or even between calls to the same function.

WinHttpSetTimeouts函数返回一个BOOL值,这个值代表成果或失败。如果失败,请调用GetLastError获取具体的失败代码,如果返回的是成功,我们又调用了GetLastError,返回的错误值号就是不可预料的,这取决于Windows的版本,补丁号等等。

Some functions, such as WinHttpConnect, return an HINTERNET pseudo handle. These functions are exactly the same, except failure is indicated by returningNULL. If NULL is returned, callers interested in the error should callGetLastError. If GetLastError is called when the function succeded (returned anything butNULL), the returned value is unpredictable and may change between Windows versions, Service Packs, or even between calls to the same function.

一些函数,如WinHttpConnect返回一个WinHttpConnect伪句柄。这些函数如果失败会返回NULL。如果返回空,调用者同样可以用GetLastError获取具体错误代码,如果GetLastError是在函数成功时调用的,返回的错误值号就是不可预料的,这取决于Windows的版本,补丁号等等。

Some functions, such as WinHttpGetProxyResult, return a DWORD error code and there is no need to call any other functions for more error information. For these functions,GetLastError should not be called. If GetLastError is called, regardless of the success or failure of the function, the returned value is unpredictable and may change between Windows versions, Service Packs, or even between calls to the same function.

一些函数,如WinHttpGetProxyResult返回一个DWORD错误代码,这就不需要我们再调用任何辅助函数来确定错误代码了。对这些函数不能使用GetLastError,如果调用了GetLastError,不管函数成功与否,返回的错误值号就是不可预料的,这取决于Windows的版本,补丁号等等。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
WinHTTP提供以下功能: WinHttpAddRequestHeaders 向HTTP请求句柄添加一个或多个HTTP请求标头。 WinHttpCheckPlatform 确定WinHTTP是否支持当前平台。 WinHttpCloseHandle 关闭单个 HINTERNET句柄。 WinHttpConnect 指定HTTP请求的初始目标服务器。 WinHttpCrackUrl 将URL分为其组成部分,例如主机名和路径。 WinHttpCreateProxyResolver 创建WinHttpGetProxyForUrlEx使用的句柄。 WinHttpCreateUrl 从组件部分创建URL,例如主机名和路径。 WinHttpDetectAutoProxyConfigUrl 查找代理自动配置(PAC)文件的URL。此功能报告PAC文件的URL,但不下载该文件。 WinHttpFreeProxyResult 释放从以前的调用WinHttpGetProxyResult检索的数据。 WinHttpGetDefaultProxyConfiguration 从注册表中检索默认的WinHTTP代理配置。 WinHTTPGetIEProxyConfigForCurrentUser 获取当前用户的Internet Explorer(IE)代理配置。 WinHttpGetProxyForUrl 检索指定URL的代理信息。 WinHttpGetProxyForUrlEx 检索指定URL的代理信息。 WinHttpGetProxyResult 检索到调用的结果WinHttpGetProxyForUrlEx。 WinHttpOpen 初始化应用程序对WinHTTP功能的使用。 WinHttpOpenRequest 创建HTTP请求句柄。 WinHttpQueryAuthSchemes 返回服务器支持的授权方案。 WinHttpQueryDataAvailable 返回可立即与读取数据的字节数 WinHttpReadData。 WinHttpQueryHeaders 检索与HTTP请求相关联的头信息。 WinHttpQueryOption 在指定的句柄上查询Internet选项。 WinHttpReadData 从WinHttpOpenRequest函数打开的句柄中读取数据 。 WinHttpReceiveResponse 结束由WinHttpSendRequest启动的HTTP请求 。 WinHttpResetAutoProxy 重置自动代理。 WinHttpSendRequest 将指定的请求发送到HTTP服务器。 WinHttpSetCredentials 将所需的授权凭证传递给服务器。 WinHttpSetDefaultProxyConfiguration 在注册表中设置默认的WinHTTP代理配置。 WinHttpSetOption 设置Internet选项。 WinHttpSetStatusCallback 设置WinHTTP可以在操作过程中进行调用的回调函数。 WinHttpSetTimeouts 设置涉及HTTP事务的各种超时。 WinHttpTimeFromSystemTime 根据HTTP版本1.0规范格式化日期和时间。 WinHttpTimeToSystemTime 获取HTTP时间/日期字符串并将其转换为 SYSTEMTIME结构。 WinHttpWriteData 将请求数据写入HTTP服务器。 WinHttpWebSocketClose 关闭WebSocket连接。 WinHttpWebSocketCompleteUpgrade 完成由WinHttpSendRequest启动的WebSocket握手。 WinHttpWebSocketQueryCloseStatus 获取服务器发送的关闭状态。 WinHttpWebSocketReceive 从WebSocket连接接收数据。 WinHttpWebSocketSend 通过WebSocket连接发送数据。 WinHttpWebSocketShutdown 向WebSocket连接发送关闭框架

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值