• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1387
  • Last Modified:

CInternetSession : undeclared identifier

With the code below, i always get: error C2065: 'CInternetSession' : undeclared identifier
Why?

CInternetSession session;
CHttpFile *httpFile = session->OpenURL("MonUrl/Mypage");
httpFile->Close();
0
mammouth
Asked:
mammouth
  • 5
  • 4
1 Solution
 
jkrCommented:
You need to

#include <afxinet.h>
0
 
mammouthAuthor Commented:
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
 
jkrCommented:
>>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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
mammouthAuthor Commented:
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
 
jkrCommented:
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
 
mammouthAuthor Commented:
Which property of httpFile will contain content of MonUrl/Mypage ?

This code give no error, but i can't found content anywhere?
0
 
jkrCommented:
You can read the contents of the page using

CString str;

while ( httpFile->ReadString(str)) {

// process string here
}
0
 
mammouthAuthor Commented:
Does wininet will work behind a proxy?
0
 
jkrCommented:
Yes, it should.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now