• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1453
  • 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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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