Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Looking for VB Wininet example.

Options
  • 15-02-2002 12:50pm
    #1
    Registered Users 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 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 Posts: 60 ✭✭asmith


    Here's the module


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


    sweet thanks. Had the module already though. :)


Advertisement