Windows XP 上的 Vb6 http post 请求 [英] Vb6 http post request on windows XP

查看:59
本文介绍了Windows XP 上的 Vb6 http post 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 VB6 发送 POST 请求时遇到问题.下面的代码在 Windows7 上正常工作,但在 Windows XP 上它运行时没有任何运行时错误并且它发送数据包但看起来它没有在数据包中附加发布数据.我的代码是这样的:

I have a problem sending POST request with VB6. The code below works properly on Windows7 but on Windows XP it run without any runtime error and it sends the packet but looks like it doesn't append the post data in the packet. My code is like this:

Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "POST", url, False
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.setRequestHeader "Content-Length", Len(parameters)
xmlhttp.Send parameters

其中参数包含字符串bar=foo&foo=bar"

where paramaters contains the string "bar=foo&foo=bar"

我已经尝试添加对 Microsoft XML v4.0 的引用.

I already tried to add the references to Microsoft XML, v4.0.

推荐答案

我找到了解决方案.我是这样修改代码的:

I found a solution. I changed the code in this way:

Dim xmlhttp As WinHttp.WinHttpRequest 
...

Set xmlhttp = New WinHttp.WinHttpRequest

xmlhttp.open "POST", url, False
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.setRequestHeader "Content-Length", Len(parameters)
xmlhttp.Send parameters

添加对Microsoft WinHTTP 服务,版本 5.1"的引用

Adding the reference to "Microsoft WinHTTP Services, version 5.1"

现在它可以工作了.

这篇关于Windows XP 上的 Vb6 http post 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆