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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Looking for VB Wininet example.

  • 15-02-2002 11:50am
    #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