MFC calls MS Internet transfer control

Source: Internet
Author: User

The project needs to obtain the HTTP webpage content. The chttpsession method is used at the beginning, but it can only be used synchronously. The interface gets stuck when the network speed is slow and the user experience is poor. the asynchronous HTTP method is considered. The Asynchronous Method of winnet is too cumbersome and time cannot be further explored. I suddenly found that the ms itc control could be used in VB, and I thought it could be used in MFC. however, when the execute method is called, parameters will not be passed. The online clear-color VB tutorial has been exploring for a long time. The implementation method is as follows:

1: Associate the control variable m_inetctrl of an ITC.

2: Construct an HTTP request

Tchar * aurl = _ T ("http://www.baidu.com"); _ variant_t url = aurl; _ variant_t method = _ T ("get"); m_intctrl.execute (URL, method, URL, URL );

3: receive in response to the event

If (State = cinet1: icresponsecompleted) {_ variant_t var; long Len = 0; colevariant ret = m_intctrl.getchunk (& Len, VAR); uses_conversion; cstring strlen = ole2a (Ret. bstrval); afxmessagebox (strlen );}

Close the work,

BTW: VC is really troublesome.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.