Posted on 2007-09-30
Last Modified: 2009-05-28
i have the below code that reads the HTML content from provided  URL.
#pragma   comment(lib,"Wininet.lib")

char buffer[100*1024] ;

int main(int argc, char* argv[])
      HINTERNET hNet = ::InternetOpen("my browser",
                                0) ;

      HINTERNET hUrlFile = ::InternetOpenUrl(hNet,
                                0) ;

      DWORD dwBytesRead = 0;
      BOOL bRead = ::InternetReadFile(hUrlFile,
      // write the HTML response into the file
      FILE *fp = freopen("html.html","w",stdout);

      ::InternetCloseHandle(hUrlFile) ;

      ::InternetCloseHandle(hNet) ;
      return 0;

above my code works for GET method, i need a workable code for POST method. example
url :
values : username = abc & password = abc123 & remember = 1

pls help if anyone know how to do this stuff.
Question by:marchent
    LVL 10

    Accepted Solution

    Hello marchent,

    You need to use OpenRequest with a "POST" verb to post data.

    But I would suggest making use of an existing wrapper class for WinInet so you don't have to worry about the internals.

    Such a wrapper class can be found here:


    LVL 17

    Expert Comment

    Consider using ServerXMLHTTP as an easier alternative too.
    LVL 13

    Author Comment

    i'm not expert on mfc or such things, i need simple code like as i showed u on example. i have simplified above code from some other example, but your one i even failed to compile :( inside webaccess there are some header file those are missing as VS6.0 says.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
    This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
    The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now