背景:代替手工自动进行PPPOE拨号
相关知识:
主要使用的函数:
The RasDial function establishes a RAS connection between a RAS client and a RAS server. The connection data includes callback and user-authentication information
DWORD RasDial(
__in LPRASDIALEXTENSIONS lpRasDialExtensions,
__in LPCTSTR lpszPhonebook,
__in LPRASDIALPARAMS lpRasDialParams,
__in DWORD dwNotifierType,
__in LPVOID lpvNotifier,
__in LPHRASCONN lphRasConn
);
Return Value
If the function succeeds, the return value is ERROR_SUCCESS and a handle to the RAS connection is returned in the variable pointed to by lphRasConn .
If the function fails, the return value is from Routing and Remote Access Error Codes or Winerror.h.
更多消息请查看 :
http://msdn.microsoft.com/en-us/library/aa377004(VS.85).aspx
RASDIALPARAMS ms;
RASDIALPARAMS params;
HRASCONN handle=NULL;
memset(&ms, '/0', sizeof(params));
params.dwSize=sizeof(RASDIALPARAMS);
CString entryname;
CString tmp;
tmp.Format("%d", i);
entryname="UE"+tmp;//需要拨号的名称,也就是建立的宽带连接的名称,如UE0
strcpy(params.szEntryName,entryname);
strcpy(params.szPhoneNumber,"");
strcpy(params.szCallbackNumber,"");
strcpy(params.szUserName,"tm500"); //用户名
strcpy(params.szPassword, "tm500"); //密码
strcpy(params.szDomain, "");
Message +="/n"+entryname+"dailying up ......";
UpdateData(TRUE);
//指定的拨号连接。
int a =RasDial(NULL, NULL, ¶ms, NULL, NULL, &handle);
if (a!=ERROR_SUCCESS)
{
MessageBox("正在拨打的计算机没有应答,稍后请再试");
Message +="/n"+entryname+"dailying up failed....../n";
UpdateData(TRUE);
DWORD off=RasHangUp(handle);
//SendMessage(WM_CLOSE);
if (off==0)
{
MessageBox("连接已断开");
//printf("连接已断开.../n");
}
else{
//printf("断开连接出错.../n");
MessageBox("断开连接出错.");
}
}