本文介绍了通过Connection Manager API建立GPRS连接时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 你好,我正在为windows mobile 6开发win32应用程序,它建立了一个GPRS连接来访问互联网资源。我正在使用的用于建立GPRS连接的代码如下: HRESULT hr = S_OK; DWORD dwIndex,dwStatus,dwErrorCode; CONNMGR_CONNECTIONINFO ci = {0}; dwIndex = dwStatus = dwErrorCode = 0; //注册连接管理器 ci.cbSize = sizeof(CONNMGR_CONNECTIONINFO); ci.dwParams = CONNMGR_PARAM_GUIDDESTNET; ci.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE; ci.guidDestNet = IID_DestNetInternet; hr = ConnMgrEstablishConnectionSync(& ci,& hConnection,30 * 1000,& dwStatus); / *检查连接状态* / //初始化应用程序使用WinInet函数。 hInternet = InternetOpen(TEXT(" Mitr-App)),INTERNET_OPEN_TYPE_DIRECT,abs_null ,abs_null,0); if(hInternet == abs_null){ dwErrorCode = GetLastError(); 返回FALSE; } / *使用 connection 通过 wininet api * / //释放连接 ConnMgrReleaseConnection(hConnection,TRUE); 这段代码的行为完全不可预测,几次运行正常,大部分时间都失败。如果出现故障情况,它返回的状态代码是 CONNMGR_STATUS_CONNECTIONFAILED 即连接失败并且无法重新建立。与此同时,我正在使用Pocket IE进行互联网,它成功建立连接并访问网络,而我不能。 请帮我解决这段代码中的问题。有人能告诉我什么是在Windows Mobile becoz中通过GPRS访问互联网的强大方法,每当我谷歌搜索我在连接管理器api上结束时。如果我运行PIE然后我的应用程序然后它工作得很好但是当我首先运行我的应用程序时它无法建立连接。 解决方案 请参阅此 http://blogs.msdn.com/windowsmobile/存档/ 2005/09/14 / 466579.aspx 结果 Hello,I'm developing win32 application for windows mobile 6 which establish a GPRS connection for accessing internet resources.Code what i'm using for establishing GPRS connection is given below :HRESULT hr = S_OK;    DWORD dwIndex, dwStatus, dwErrorCode ;CONNMGR_CONNECTIONINFO ci = {0};   dwIndex = dwStatus = dwErrorCode = 0;// Register with the connection manager ci.cbSize = sizeof(CONNMGR_CONNECTIONINFO);  ci.dwParams = CONNMGR_PARAM_GUIDDESTNET;   ci.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE; ci.guidDestNet = IID_DestNetInternet ;   hr = ConnMgrEstablishConnectionSync(&ci, &hConnection, 30*1000, &dwStatus);   /*checking the connection status*/   //initializing application's use of the WinInet functions.   hInternet = InternetOpen(TEXT("Mitr-App"), INTERNET_OPEN_TYPE_DIRECT, abs_null, abs_null, 0);   if (hInternet == abs_null){        dwErrorCode = GetLastError();        return FALSE;                    }/* using the connection through wininet api*/// releasing the connectionConnMgrReleaseConnection(hConnection, TRUE); The behaviour of this code is totally unpredictable few times it works fine and most of the times it fails.In case of fail scenario it returns the status code is CONNMGR_STATUS_CONNECTIONFAILED ie The connection failed and cannot be reestablished.At the same time i'm using Pocket IE for brwosing internet it successfully establish the connection and access the network while i cann't. Please help me whats worng in this code.Can anyone tell me what is robust method for accessing internet through GPRS in windows mobile becoz whenever i'm googling i endup on connection manager api.If i run PIE first then my app then it works perfectly fine but when i run my app first its not able to establish the connection. 解决方案 Hi,Refer this http://blogs.msdn.com/windowsmobile/archive/2005/09/14/466579.aspx 这篇关于通过Connection Manager API建立GPRS连接时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-18 18:34