[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

CInternetSession : undeclared identifier

Posted on 2004-10-29
9
Medium Priority
?
1,358 Views
Last Modified: 2008-01-09
With the code below, i always get: error C2065: 'CInternetSession' : undeclared identifier
Why?

CInternetSession session;
CHttpFile *httpFile = session->OpenURL("MonUrl/Mypage");
httpFile->Close();
0
Comment
Question by:mammouth
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 12445151
You need to

#include <afxinet.h>
0
 
LVL 1

Author Comment

by:mammouth
ID: 12445208
Now i get:

error C2819: type 'CInternetSession' does not have an overloaded member 'operator ->'

If i replace the "->" with "." i get

error C2440: 'initializing' : cannot convert from 'CStdioFile *' to 'CHttpFile *'

Please help
0
 
LVL 86

Expert Comment

by:jkr
ID: 12445579
>>error C2440: 'initializing' : cannot convert from 'CStdioFile *' to 'CHttpFile *'

Um, 'OpenURL()' indeed returns that:

CStdioFile* OpenURL( LPCTSTR pstrURL, DWORD dwContext = 1, DWORD dwFlags = INTERNET_FLAG_TRANSFER_ASCII, LPCTSTR pstrHeaders = NULL, DWORD dwHeadersLength = 0 );

Are you thinking of

CInternetSession session;
CHttpConnection *httpConn = session.GetHttpConnection(...);
CHttpFile *httpFile = httpConn->OpenRequest(...);

?

0
Technology Partners: 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!

 
LVL 1

Author Comment

by:mammouth
ID: 12445642
What i want to do, is get html content from a webpage into a variable like inet.openurl under vb.

CInternetSession session;
CHttpConnection *httpConn = session.GetHttpConnection(...);
CHttpFile *httpFile = httpConn->OpenRequest(...);

give me error:
error C2661: 'CHttpConnection::OpenRequest' : no overloaded function takes 1 arguments

0
 
LVL 86

Expert Comment

by:jkr
ID: 12445892
You'll need to supply the correct arguments. BTW,  you can read the content via a CStdioFile also:

CInternetSession session;
CStdioFile *httpFile = session.OpenURL("MonUrl/Mypage");
httpFile->Close();
0
 
LVL 1

Author Comment

by:mammouth
ID: 12446537
Which property of httpFile will contain content of MonUrl/Mypage ?

This code give no error, but i can't found content anywhere?
0
 
LVL 86

Accepted Solution

by:
jkr earned 160 total points
ID: 12446791
You can read the contents of the page using

CString str;

while ( httpFile->ReadString(str)) {

// process string here
}
0
 
LVL 1

Author Comment

by:mammouth
ID: 12446835
Does wininet will work behind a proxy?
0
 
LVL 86

Expert Comment

by:jkr
ID: 12446898
Yes, it should.
0

Featured Post

Technology Partners: 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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

649 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