如何在vb6中的inet中使用代理?

发布于 2024-11-06 18:45:15 字数 70 浏览 0 评论 0原文

我正在用 vb6 编写一个程序。 我想通过 vb6 中的 inet 使用代理进行连接。怎么办呢?请帮忙。

谢谢

I'm making a program in vb6.
i;d like to connect using a proxy through inet in vb6. how to o it? please help.

thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笨笨の傻瓜 2024-11-13 18:45:15

这是一个或多或少通用的函数,用于打开可以采用代理参数的互联网连接。这是如何使用代理的一个很好的例子。

Private Declare Function InternetOpen Lib "WinInet" Alias "InternetOpenA" (ByVal lpszAgent As String, ByVal lpAccessType As Long, ByVal lpszProxyName As String, ByVal lpszProxyBypass As String, ByVal lpFlags As Long) As Long

Public Function OpenInternet(ByVal sAppName As String, ByVal lAccessType As Long,  ByVal sProxyName As String, _
   ByVal sProxyBypass As String, ByVal lFlags As Long) As Boolean
   Dim Rtn As Long
   Dim lngINetHandle As Long
   Dim strHeaders As String
   Dim lngDllErr As Long

   On Error GoTo errOpenInternet

   RaiseEvent Operation("Opening internet connection")
   Rtn = InternetOpen(ByVal sAppName, ByVal lAccessType, ByVal sProxyName, ByVal sProxyBypass, ByVal lFlags)

   If Rtn = 0 Then   'failed for some reason
      lngDllErr = Err.LastDllError
      If lngDllErr <> 0 Then
         RaiseEvent Operation("Error " & CStr(lngDllErr))
         Err.Raise lngDllErr, "OpenInternet", ErrorOut(Err.LastDllError, "OpenInternet")
      End If
   Else
      RaiseEvent Operation("Connection opened")
      InternetHandle = Rtn
      ExtendedError = ""
   End If

   OpenInternet = CBool(Rtn)

   Exit Function

errOpenInternet:
   Err.Raise Err.Number, Err.Source & ":OpenInternet", Err.Description

End Function

This is a more or less generic function to open an internet connection that can take proxy parameters. It is a good example of how a proxy is used.

Private Declare Function InternetOpen Lib "WinInet" Alias "InternetOpenA" (ByVal lpszAgent As String, ByVal lpAccessType As Long, ByVal lpszProxyName As String, ByVal lpszProxyBypass As String, ByVal lpFlags As Long) As Long

Public Function OpenInternet(ByVal sAppName As String, ByVal lAccessType As Long,  ByVal sProxyName As String, _
   ByVal sProxyBypass As String, ByVal lFlags As Long) As Boolean
   Dim Rtn As Long
   Dim lngINetHandle As Long
   Dim strHeaders As String
   Dim lngDllErr As Long

   On Error GoTo errOpenInternet

   RaiseEvent Operation("Opening internet connection")
   Rtn = InternetOpen(ByVal sAppName, ByVal lAccessType, ByVal sProxyName, ByVal sProxyBypass, ByVal lFlags)

   If Rtn = 0 Then   'failed for some reason
      lngDllErr = Err.LastDllError
      If lngDllErr <> 0 Then
         RaiseEvent Operation("Error " & CStr(lngDllErr))
         Err.Raise lngDllErr, "OpenInternet", ErrorOut(Err.LastDllError, "OpenInternet")
      End If
   Else
      RaiseEvent Operation("Connection opened")
      InternetHandle = Rtn
      ExtendedError = ""
   End If

   OpenInternet = CBool(Rtn)

   Exit Function

errOpenInternet:
   Err.Raise Err.Number, Err.Source & ":OpenInternet", Err.Description

End Function
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文