|
引用 1 楼 91program 的回复:
想让别人帮你分析问题,最好给出比较完整的代码
你认为是RasDialFunc的问题,难道一定是它的问题!
哦,谢谢,我还以为就这么点代码就够了
m_hRasConn=NULL;
memset ((char *)&RasDialParams, 0, sizeof(RasDialParams));
RasDialParams.dwSize = sizeof(RasDialParams);
wcscpy(RasDialParams.szEntryName,szEntry);
wcscpy(RasDialParams.szPhoneNumber,_T(""));
wcscpy(RasDialParams.szCallbackNumber,_T(""));
wcscpy(RasDialParams.szUserName,_T(""));
wcscpy(RasDialParams.szPassword,_T(""));
wcscpy(RasDialParams.szDomain,_T(""));
// nRet=RasSetEntryDialParams(NULL, &RasDialParams, FALSE);
// 以下是同步拨号模式
HWND hWnd;
DWORD dwRet;
// dwRet=RasDial(NULL,NULL,&RasDialParams,0xFFFFFFFF,hWnd, &m_hRasConn);
dwRet=RasDial(NULL,NULL,&RasDialParams,0,RasDialFunc,&m_hRasConn);
if(dwRet!=0)
{
RasHangUp(m_hRasConn);
return FALSE;
}
void WINAPI CDemoDlg::RasDialFunc(UINT unMsg,RASCONNSTATE rasconnstate,DWORD dwError)
{
CDemoDlg *DemoDlg=(CDemoDlg*)AfxGetApp()->m_pMainWnd;
DemoDlg->PostMessage(WM_RASDIALEVENT,(WPARAM)rasconnstate,(LPARAM)rasconnstate);
CString str;
switch(rasconnstate)
{
case RASCS_OpenPort:
str= "正在打开端口...";
break;
case RASCS_PortOpened:
str= "端口已经打开";
break;
case RASCS_ConnectDevice:
str= "正在连接设备";
break;
case RASCS_DeviceConnected:
str= "设备已经连接";
break;
case RASCS_AllDevicesConnected:
str= "所有设备已经连接上";
break;
代码片段 |
|