Windows mobile 根据网络地址自动拨号连接GRPS

BOOL Dial(CString szURL)
{
	GUID guid;
	HANDLE iConnectionHandle = ConnMgrApiReadyEvent();
	HRESULT hresult = ConnMgrMapURL((LPCTSTR)szURL,&guid,NULL);
	if (FAILED(hresult))
	{
		MessageBox(L"映射地址不成功",L"错误",MB_OKCANCEL);
		return FALSE;
	}
	// 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);
	if (FAILED(hresult))
	{
		MessageBox(L"拨号不成功",L"错误",MB_OKCANCEL);
		return FALSE;
	}
	return TRUE;
}

posted on 2011-03-25 10:37  lartely  阅读(238)  评论(0编辑  收藏  举报

导航