[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

WININET POST Method

Posted on 2007-09-30
3
Medium Priority
?
1,487 Views
Last Modified: 2009-05-28
i have the below code that reads the HTML content from provided  URL.
///////////////////////////////////////////////////
#include<windows.h>
#include<wininet.h>
#include<stdio.h>
#pragma   comment(lib,"Wininet.lib")

char buffer[100*1024] ;

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

      HINTERNET hUrlFile = ::InternetOpenUrl(hNet,
                                "http://www.google.com/",
                                NULL,
                                0,
                                INTERNET_FLAG_RELOAD,
                                0) ;

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

      ::InternetCloseHandle(hUrlFile) ;

      ::InternetCloseHandle(hNet) ;
      return 0;
}
///////////////////////////////////////

above my code works for GET method, i need a workable code for POST method. example
url : http://www.myeeque.com/login/?
values : username = abc & password = abc123 & remember = 1

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

Accepted Solution

by:
archang3l earned 750 total points
ID: 19988914
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: http://www.codeproject.com/internet/wininet_wrapper_part1.asp

Regards,

archang3l
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 19989389
Consider using ServerXMLHTTP as an easier alternative too.
0
 
LVL 13

Author Comment

by:marchent
ID: 19989667
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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

830 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