I'm trying to access data using HTTP by calling CInternetSession::OpenUrl on Windows Mobile 5 (coding in C++ with MFC). I always get an exception with error code 12029 (cannot connect).
I suspect that I need to use the Connection Manager API to create a connection first. Can someone confirm that?
I am going to try coding it up, based on information here (http://msdn.microsoft.com/en-us/magazine/dd263096.aspx), and I'll report my experiences as an answer if appropriate. It would be nice to get other input too.
I have successfully opened a connection using this code:
// Find out which type of connection is needed for this URL.
GUID guid;
HRESULT hresult = ConnMgrMapURL((LPCTSTR)url,&guid,NULL);
if (!SUCCEEDED(hresult))
{
delete [] url;
aError = CartoType::KErrorInternetIo;
return NULL;
}
// Get a connection.
CONNMGR_CONNECTIONINFO cinfo;
memset(&cinfo,0,sizeof(cinfo));
cinfo.cbSize = sizeof(cinfo);
cinfo.bDisabled = FALSE;
cinfo.bExclusive = FALSE;
cinfo.guidDestNet = guid;
cinfo.dwParams = CONNMGR_PARAM_GUIDDESTNET;
cinfo.dwFlags = CONNMGR_FLAG_PROXY_HTTP;
cinfo.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;
DWORD status;
hresult = ConnMgrEstablishConnectionSync(&cinfo,&iConnectionHandle,15000,&status);
and I know that it worked because it sets status to CONNMGR_STATUS_CONNECTED
; nevertheless, I call CInternetSession::OpenURL
immediately afterwards and it throws an exception.