A website for better software and better life in Internet!

   Chinese URLs

   Greeting Creator

   Input Tips Everyday

   Source Code
Java Applet Games
Visit webpage in VC
M3U Music List Editor
Input Tips Everyday
Combox in HTML
Self-made Screen Saver
Model of Neural Network
Display Chinese Characters
Mouse in Maze, a classic game in math
Serial Port Communication

Source Code -> Read Web Pages in VC: GET

Read Web pages, and GET method

Next page: POST data as a form.

There's 2 ways to send data to web. One is GET, another is POST

You can read RFC for difference between GET and POST, but briefly, when you read ¡°http://server/cgi.dll?a=1&b=2&c=3&d=4¡±, you are sending data "a=1, b=2, c=3, d=4" to "http://server/cgi.dll" this CGI program, using GET method.

In MFC, CHttpFile is a subclass of CStdioFile. After you open a file in Internet using CHttpFile, you can ReadString like CStdioFile. You must use CInternetSession to open internet file.

Here is a part of source code of Chinese URL System, this function find new template and input it into Chinese URL System. Application Get handle from sess.OpenURL(strFileName) and then fileGet->QueryInfo to check status of this file. If success, the return value should be 200-299. After that, we can read that web file like usual:

Now, you know how to read page, you then you can send data using GET method. For example, when you read "http://www.fadshop.net/curl/progsave.asp?curl=&http=http://www.china.com", you are submitting your website to server of Chinese URL System.

But, you can not sent too many data using GET method. Then you should use POST. you can read next page: POST data

Source code below is verified using NT4, Visual C6.0
CString strWriteName="Template01.htm"
#ifndef _DEBUG
    strFileName="http://www.fadshop.net/curl/" + strWriteName;
#else    //In DEBUG version, read from my IIS.
    strFileName="" + strWriteName;
    CInternetSession sess;//Create session
    CHttpFile* fileGet;
    CException* e;
        fileGet=(CHttpFile*)sess.OpenURL(strFileName);//Open file
        fileGet = 0;

        DWORD dwStatus;
        DWORD dwBuffLen = sizeof(dwStatus);
        BOOL bSuccess = fileGet->QueryInfo(
            &dwStatus, &dwBuffLen);

        if( bSuccess && dwStatus>=  200&& dwStatus<300 ) 
            { CStdioFile     fileWrite; 
            if(fileWrite.Open(strWriteName, CFile::modeWrite|CFile::modeCreate))
                SetDlgItemText(IDC_DOWNMSG, "Downloaded, installing...");
                How to install, it's none of our business
             }// if openfile success.
                else SetDlgItemText(IDC_DOWNMSG,
                "Local file"+strWriteName+"Error\n"); 
            }// if bSuccess.
            else SetDlgItemText(IDC_DOWNMSG, "No new template.\n
                Please run it later, or visit my homepage for further message");
        delete fileGet;
        SetDlgItemText(IDC_DOWNMSG, "Network Problem");

   Contact Info
  User Support Sales Question Webmaster

Copyright 1998-2002 Fadshop.net, Inc. All rights reserved.