Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I send a simple HTTP request? 1

Status
Not open for further replies.

deadpool42

Programmer
May 24, 2004
40
The code I have right now (copied from Microsoft's website) is this:
Code:
    Dim hInternetSession       As Long
    Dim hInternetConnect       As Long
    Dim hHttpOpenRequest       As Long
    Dim sBuffer               As String * 1024
    Dim lBufferLength         As Long
    lBufferLength = Len(sBuffer)
    hInternetSession = InternetOpen(scUserAgent, _
        INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
    hInternetConnect = InternetConnect(hInternetSession, _
         "team.monkeycrap.com", INTERNET_DEFAULT_HTTP_PORT, _
         vbNullString, vbNullString, INTERNET_SERVICE_HTTP, 0, 0)
    hHttpOpenRequest = HttpOpenRequest(hInternetConnect, "GET", _
         "/cgi-bin/clan.pl?action=setserver&player=" + clanMember + "&server=" + serverIP + "&port=" + serverPort, "HTTP/1.0", vbNullString, 0, _
         INTERNET_FLAG_RELOAD, 0)
    HttpSendRequest hHttpOpenRequest, vbNullString, 0, 0, 0

but Visual Basic tells me the function InternetOpen isn't defined. I've tried adding wininet.dll to the project's references, but that doesn't work either. I just need to send a GET request, I don't even care about the page being returned. Does anyone know the best way to do this?
 
You need to declare the InternetOpen API function in your application to have access to it. Put this in a module:

Public Declare Function InternetOpen Lib "wininet.dll" _
Alias "InternetOpenA" _
(ByVal lpszAgent As String, _
ByVal dwAccessType As Long, _
ByVal lpszProxyName As String, _
ByVal lpszProxyBypass As String, _
ByVal dwFlags As Long) As Long


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top