|
如何在RAS异步拨号时,得到当前拨号的状态,我写的消息和回调函数都可以在PC机上用,但在CE上都不能用(CE只支持消息),代码如下:消息的、
先注册了消息:
const UINT WM_RASEVENT = ::RegisterWindowMessage(_T(RASDIALEVENT));
然后配置消息:
BEGIN_MESSAGE_MAP(CGprsStateDlg, CDialog)
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
ON_WM_SIZE()
#endif
//}}AFX_MSG_MAP
ON_REGISTERED_MESSAGE(WM_RASEVENT,OnRasDialEvent)
然后定义函数:
LRESULT CGprsStateDlg::OnRasDialEvent(WPARAM wp, LPARAM lp)
{
RASCONNSTATE rasstate = (RASCONNSTATE)wp;
CDState cs;
cs.DoModal();
switch(rasstate)
{
case RASCS_OpenPort:
cs.m_s = _T("打开端口……");
break;
case RASCS_PortOpened:
cs.m_s = _T("端口已打开……");
break;
case RASCS_ConnectDevice:
break;
case RASCS_DeviceConnected:
AfxGetApp()->GetMainWnd()->GetDlgItem(IDC_STATIC_STATE)->SetWindowTextW(_T("设备已连接.…"));
//info→AddString(_T(″设备已连接.″));
break;
case RASCS_Authenticate:
cs.m_s = _T("验证用户及密码……");
break;
case RASCS_Authenticated:
info→AddString(_T(″通过″));
break;
case RASCS_Connected:
cs.m_s = _T("已连接");
break;
case RASCS_Disconnected:
m_hRasConn=NULL;
break;
default:
return (LRESULT)0;
}
//cs.EndDialog(5);
return (LRESULT)0;
}
然后开始拨号:
RASDIALPARAMS rdParams;
m_hRasConn = NULL;
//初始化变量
rdParams.dwSize = sizeof(RASDIALPARAMS);
wcscpy(rdParams.szEntryName,_T("我的连接"));//_T("我的连接")//lpszName
wcscpy(rdParams.szPhoneNumber,_T("*99***1#"));
wcscpy(rdParams.szCallbackNumber,_T("*"));
wcscpy(rdParams.szUserName,_T(""));
wcscpy(rdParams.szPassword,_T(""));
wcscpy(rdParams.szDomain,_T(""));
DWORD dwRet;
//dwRet = RasDial(NULL,NULL,&rdParams,0L,RasDialFunc,&m_hRasConn);//异步回调
dwRet = RasDial(NULL,NULL,&rdParams,0xFFFFFFFF,this->m_hWnd,&m_hRasConn); //异步消息
if ( dwRet != 0 )
{
RasHangUp(m_hRasConn);
return;
}
return ;
}
可是无法得到当前状态,但在PC机上,一样的代码是正确无误的。请各位高手大牛指点。
|
|