WEB开发网
开发学院手机开发Windows Mobile 开发 Windows Mobile下连接移动GPRS 阅读

Windows Mobile下连接移动GPRS

 2010-08-22 12:41:00 来源:WEB开发网   
核心提示:}int Index =0;//查找“WAP”的索引for (int i = 0; i < StrAry.GetCount(); ++i){if (StrAry[i] == L"WAP"){Index = i;break;}}// 得到正确的连接信息CONNMGR_DESTINATION_IN

}

int Index =0;

//查找“WAP”的索引

for (int i = 0; i < StrAry.GetCount(); ++i)

{

if (StrAry[i] == L"WAP")

{

Index = i;

break;

}

}

// 得到正确的连接信息

CONNMGR_DESTINATION_INFO DestInfo = {0};

HRESULT hResult = ConnMgrEnumDestinations(Index, &DestInfo);

BOOL bRet = FALSE;

if(SUCCEEDED(hResult))

{

// 初始化连接结构

CONNMGR_CONNECTIONINFO ConnInfo;

ZeroMemory(&ConnInfo, sizeof(ConnInfo));

ConnInfo.cbSize = sizeof(ConnInfo);

ConnInfo.dwParams = CONNMGR_PARAM_GUIDDESTNET;

ConnInfo.dwFlags = CONNMGR_FLAG_PROXY_HTTP | CONNMGR_FLAG_PROXY_WAP | CONNMGR_FLAG_PROXY_SOCKS4 | CONNMGR_FLAG_PROXY_SOCKS5;

ConnInfo.dwPriority = CONNMGR_PRIORITY_HIPRIBKGND;//CONNMGR_PRIORITY_USERINTERACTIVE;

ConnInfo.guidDestNet = DestInfo.guid;

ConnInfo.bExclusive = FALSE;

ConnInfo.bDisabled = FALSE;

DWORD dwStatus = 0;

hResult = ConnMgrEstablishConnectionSync(&ConnInfo, &m_hConnection, 100*1000, &dwStatus );

// if(FAILED(hResult))

// {

// MessageBox(NULL,L"连接失败",L"错误信息",MB_OK);

// m_hConnection = NULL;

// }

// else

// {

// MessageBox(NULL,L"连接成功",L"错误信息",MB_OK);

// return TRUE;

// }

}

上面两段代码仅限于连接移动的GPRS。注意:m_hConnection最好设成全局变量,这样程序退出时关闭GPRS

所需的头文件和lib库

#include

#include

#pragma comment( lib, "cellcore.lib" )

上一页  1 2 

Tags:Windows Mobile 连接

编辑录入:coldstar [复制链接] [打 印]
赞助商链接