Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Looking for VB Wininet example.

  • 15-02-2002 12:50PM
    #1
    Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭


    I found a couple, but I'm really only looking for the API's that would deal directly with pulling the contents of a HTTP URL into a variable. Is this possible?

    I'm not worried about parsing as it will be in non HTML Format.


Comments

  • Registered Users, Registered Users 2 Posts: 60 ✭✭asmith


    Try this using the attached module...

    Private Function makeCall(Server As String, port As Integer, ServletPath As String) As String

    Dim iRetVal As Integer
    Dim bDoLoop As Boolean
    Dim sReadBuffer As String * 2048
    Dim lNumberOfBytesRead As Long
    Dim sBuffer As String

    hInternetSession = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
    hInternetConnect = InternetConnect(hInternetSession, Server, port, vbNullString, vbNullString, INTERNET_SERVICE_HTTP, 0, 0)
    hHttpOpenRequest = HttpOpenRequest(hInternetConnect, "GET", ServletPath, "HTTP/1.0", vbNullString, 0, INTERNET_FLAG_RELOAD, 0)
    iRetVal = HttpSendRequest(hHttpOpenRequest, vbNullString, 0, 0, 0)

    bDoLoop = True

    While bDoLoop
    sReadBuffer = vbNullString
    bDoLoop = InternetReadFile(hHttpOpenRequest, sReadBuffer, Len(sReadBuffer), lNumberOfBytesRead)
    sBuffer = sBuffer & Left$(sReadBuffer, lNumberOfBytesRead)
    If Not CBool(lNumberOfBytesRead) Then bDoLoop = False
    Wend

    makeCall = sBuffer

    On Error Resume Next
    InternetCloseHandle (hHttpOpenRequest)
    InternetCloseHandle (hInternetSession)
    InternetCloseHandle (hInternetConnect)

    End Function


  • Registered Users, Registered Users 2 Posts: 60 ✭✭asmith


    Here's the module


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    sweet thanks. Had the module already though. :)


Advertisement