Link to home
Start Free TrialLog in
Avatar of mammouth
mammouth

asked on

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();
Avatar of jkr
jkr
Flag of Germany image

You need to

#include <afxinet.h>
Avatar of mammouth
mammouth

ASKER

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
>>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(...);

?

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

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();
Which property of httpFile will contain content of MonUrl/Mypage ?

This code give no error, but i can't found content anywhere?
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Does wininet will work behind a proxy?
Yes, it should.