龙空技术网

VB6NetV2.1库Get和Post请求支持特殊字符教程

vb6plus 144

前言:

如今朋友们对“vbnethttpsget”大致比较讲究,大家都想要剖析一些“vbnethttpsget”的相关资讯。那么小编在网络上收集了一些有关“vbnethttpsget””的相关资讯,希望你们能喜欢,同学们一起来学习一下吧!

1、将VB6NetV2.1.dll放入工程目录。

如果开发环境提示找不到库,可以放到System32或SysWOW64目录。生产环境没有这个问题。

2、创建mVB6NetV2.bas文件

添加引用声明

Public Declare Sub HTTPClient_GetPtr Lib "VB6NetV2.1.dll" (ByRef URL As String, ByRef RequestHeaders As String, ByVal ResponseHeadersPtr As Long, ByVal ResponseBodyPtr As Long, Optional ByVal IsUTF8 As Integer = 1, Optional ByVal ConnectTimeOut As Integer = 5, Optional ByVal TimeOut As Integer = 60, Optional ByVal ResponseAutoDecode As Integer = 1)

Public Declare Function HTTPClient_Post Lib "VB6NetV2.1.dll" (ByRef URL As String, ByRef PostDatas As String, Optional ByRef RequestHeaders As String = "Content-Type:application/x-www-form-urlencoded", Optional ByRef ResponseHeaders As String = "", Optional ByVal IsUTF8 As Integer = 1, Optional ByVal ConnectTimeOut As Integer = 5, Optional ByVal TimeOut As Integer = 60, Optional ByVal PostDataAutoEncode As Integer = 1, Optional ByVal ResponseAutoDecode As Integer = 1) As String

3、添加测试窗体

4、双击[Get测试]按钮,添加代码

Private Sub Command2_Click()

Dim RequestHeader As String

Dim ResponseHeaders As String, OutStr As String

HTTPClient_GetPtr ";, RequestHeader, VarPtr(ResponseHeaders), VarPtr(OutStr)

TextBox2.Text = OutStr

End Sub

5、双击[Post测试]按钮,添加代码

Private Sub Command1_Click()

Dim RequestHeader As String

Dim StrPostData As String

Dim ResponseHeaders As String, OutStr As String

RequestHeader = "Content-Type:application/x-www-form-urlencoded;"

StrPostData = TextBox1.Text

HTTPClient_PostPtr ";, VarPtr(StrPostData), RequestHeader, VarPtr(ResponseHeaders), VarPtr(OutStr)

TextBox2.Text = OutStr

End Sub

6、运行效果

Get测试

Post测试

标签: #vbnethttpsget